Solved

insertparameters.add - integer

Posted on 2006-11-13
5
962 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 500 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

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…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

726 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