Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

insertparameters.add - integer

Posted on 2006-11-13
5
Medium Priority
?
985 Views
Last Modified: 2008-02-07
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
Comment
Question by:doolinn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 28

Expert Comment

by:strickdd
ID: 17930049
Try passing a string instead of and int.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17930235
What is the error?

Bob
0
 
LVL 35

Accepted Solution

by:
YZlat earned 2000 total points
ID: 17930441
ObjectDataSource1.InsertParameters.Add("DDLValue",TypeCode.Int32,DDL.ToString());
0
 
LVL 11

Expert Comment

by:Vivek Thangaswamy
ID: 17931055
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
 

Author Comment

by:doolinn
ID: 17932779
thanks YZlat - the "Typecode.Int32,DDL.ToString()" addition did the trick.  
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question