insertparameters.add - integer

I have the following that works fine to insert text into a database from a gridview:-

string Label1 =((TextBox)GridView1.FooterRow.FindControl ("txtLabel1")).Text;
ObjectDataSource1.InsertParameters.Add("Label1",Label1);
ObjectDataSource1.Insert();

What is the equivalent for an integer (based on the selected value from a dropdownlist)?

so far I've tried:-

int DDL = Convert.To Int32(((DropDownList)GridView1.FooterRow.FindControl("DDL1").SelectedValue);
ObjectDataSource1.InsertParameters.Add("DDLValue",DDL);
ObjectDataSource1.Insert();

but it returns an error on the insertparameters.add line

Thanks!
 
doolinnAsked:
Who is Participating?
 
YZlatConnect With a Mentor Commented:
ObjectDataSource1.InsertParameters.Add("DDLValue",TypeCode.Int32,DDL.ToString());
0
 
strickddCommented:
Try passing a string instead of and int.
0
 
Bob LearnedCommented:
What is the error?

Bob
0
 
Vivek ThangaswamyCommented:
If you are using .NET 2.0 the try this way

SqlCommand.Parameters.AddWithValue("@MyValue","Value");

for more
http://vivekthangaswamy.blogspot.com/2006/09/systemdatasqlclientsqlparametercollect.html
0
 
doolinnAuthor Commented:
thanks YZlat - the "Typecode.Int32,DDL.ToString()" addition did the trick.  
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.