Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 992
  • Last Modified:

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!
 
0
doolinn
Asked:
doolinn
1 Solution
 
strickddCommented:
Try passing a string instead of and int.
0
 
Bob LearnedCommented:
What is the error?

Bob
0
 
YZlatCommented:
ObjectDataSource1.InsertParameters.Add("DDLValue",TypeCode.Int32,DDL.ToString());
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now