Last post Feb 24, 2012 06:46 PM by cherieformacion
Feb 23, 2012 07:07 PM|cherieformacion|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 07:32 PM|smcoxon|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 23, 2012 08:28 PM|venkatmca008|LINK
hi..please refer this
Feb 24, 2012 09:39 AM|superguppie|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 12:06 PM|cherieformacion|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 06:46 PM|cherieformacion|LINK
I got it to work!! Yay!!
Tons of thanks to all who helped out. :)