?
Solved

insertparameters.add - integer

Posted on 2006-11-13
5
Medium Priority
?
971 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

752 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