1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

ASP.NET quickie (c#)

Discussion in 'HTML, Graphics & Programming' started by Scarylion, 15 Jan 2006.

  1. Scarylion

    Hitman

    Joined: 21 Oct 2002

    Posts: 535

    Hi chaps right im in a bit of a pickle with some .NET.

    I have a DropDownList which is populated with data from a Access Database, what im trying to do is get it to store the selected item from the list in another table, but it keeps giving me the following error on this line of code:-
    Code:
    dr["syndicate"]=DropDownList1.SelectedItem.Text;
    heres the error:

    System.FormatException: Input string was not in a correct format. at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at System.String.System.IConvertible.ToInt32(IFormatProvider provider) at System.Convert.ToInt32(Object value) at System.Data.Common.Int32Storage.Set(Int32 record, Object value) at System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn't store <Another Syndicate> in syndicate Column. Expected type is Int32.

    its getting on my **** a bit, heres my code

    Code:
    		private void Button2_Click(object sender, System.EventArgs e)
    		{
    			myDataAdapter.Fill(dsPeople1,"Users");
    			DataRow dr =dsPeople1.Tables["Users"].NewRow();
    			dr["U_name"]=TextBox2.Text;
    			dr["email"]=TextBox3.Text;
    			dr["syndicate"]=DropDownList1.SelectedItem.Text;
    			dsPeople1.Tables["Users"].Rows.Add(dr);
    			myDataAdapter.Update(dsPeople1,"Users");
    			myDataAdapter.Fill(dsPeople1,"Users");
    			DataGrid1.DataSource=dsPeople1;
    			DataGrid1.DataBind();
    		}
     
  2. voodooflux

    Hitman

    Joined: 6 Nov 2003

    Posts: 971

    Location: Redditch

    Looks like the type for the syndicate column is "number", and you're trying to insert a non-numeric value from the drop down list?

    cheers
    v.f.
     
  3. Scarylion

    Hitman

    Joined: 21 Oct 2002

    Posts: 535

    ha yeah it was, im a spaz ;)
     
  4. voodooflux

    Hitman

    Joined: 6 Nov 2003

    Posts: 971

    Location: Redditch

    Welcome to the club ;)