Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 24, 2012 10:46 PM by cherieformacion
Feb 23, 2012 11:07 PM|LINK
Most examples I found are passing text values and I need it to be an integer. I need to be able to use this value as a parameter for a gridview control associated with an SQL database. Please help... any insight would be appreciated.
Feb 23, 2012 11:32 PM|LINK
Hi, look at using Session state to store your values. You can store many data types in session. All you need to do when reading back session variables is to cast the session value to the correct type. For example:
Dim myInt as Integer = 5
'Save to session
session("myInt") = myInt
'Read it back
Dim readInt as Integer = CType(Session.Item("myInt"), Integer)
or in C#
int myInt = 5;
//Save to session
session("myInt") = myInt;
//Read it back
int readInt = Convert.ToInt32(Session.Item("myInt"));
Feb 24, 2012 12:28 AM|LINK
hi..please refer this
Feb 24, 2012 01:39 PM|LINK
By pass to another page, do you mean through QueryString? If so, know that QueryString values are always strings. You can convert them to int using int.Parse.
However, if you put a string in a Parameter of an SqlCommand (or use QueryStringParameter in the SelectParameters of an SqlDataSource) you won't even need to do that. Parameters are usually smart enough to make the Sql server do the hard work.
Feb 24, 2012 04:06 PM|LINK
Thanks for the responses :)
superguppie - Ultimately I want to use the string in the QueryStringParameter in the Select Parameters of SqlDataSource. I tried doing this and it doesn't work, no results in my gridview. Below are the codes I used. Please advice... thanks!
CodeBehind on the first page where users select from a RadioButtonList:
Select Statement on the second page:
="SELECT tblDescriptors.IDNO, tblDescriptors.Lastname, tblDescriptors.Firstname, tblDescriptors.SSNO, tblDescriptors.Birthdate, tblProgram.ProgramEntryDate, tblProgram.TerminationDate, CASE WHEN tblprogram.terminationdate IS NULL THEN 'Active' ELSE 'Inactive'
END AS Status, tblProgram.ProgramID FROM tblDescriptors INNER JOIN tblProgram ON tblDescriptors.IDNO = tblProgram.IDNO WHERE (tblProgram.ProgramID = @programid)">
<asp:QueryStringParameter Name="programid" QueryStringField="ProgramID" Type="Object" />
Feb 24, 2012 10:46 PM|LINK
I got it to work!! Yay!!
Tons of thanks to all who helped out. :)