Hi,
I'm having trouble passing a parameter from my default.aspx page to my
default2.aspx page.
I have values from a query in a list box and the goal is to pass the
"catID" from default.aspx to a stored procedure on the details2.aspx
page.
I can successfully pass the values from the listbox control to a
textbox on the page (done to eliminate other sources of error).
===========
DEFAULT.ASPX
============
Here is the listbox data (works fine when tested with a textbox):
listbox1.DataTextField="catDesc";
listbox1.DataValueField="catID"; <---- this is the data I will want
to use as @catID
All other things being checked (e.g. connection string), here is the
code snippet.
Am I using the parameter wrong?
cmd2.CommandType = CommandType.StoredProcedure;
SqlParameter sqlPrm = new SqlParameter("@catID",
ListBox1.SelectedValue);
cmd2.Parameters.Add(sqlPrm);
==========
DEFAULT2.ASPX
===========
I'm trying to pass the parameter (which should be an integer form the
catID) to TextBox1 to make sure that the process is working before I
mess with adding the parameter to a stored procedure. Here is the
"retrieval" code:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string temp;
temp = Request.Params["catID"];
TextBox1.Text = temp;
}
}
Any advice is much appreciated.
Thanks in advance,
Ranginald