Saturday, March 24, 2012

Passing 2 Parameters from Datalist Control?

I have master/detail pages and pass a parameter from master page (datalist control) to detail page using session method.

Session.Add(

"prm_type", DataList1.SelectedValue);
Response.Redirect("detail.aspx");

The code, I had placed in the datalist "selectedindexchanged" method, above works well. In addition to this, I placed a textbox control in the datalist control to pass a second parameter to detail page. But i don't know how to reach that textbox value and pass the parameter to detail page within datalist selectedindexchanged method like above. I tried something like below, but i couldn't figure out.

Session.Add("prm_quantity", ? this must be my textbox control value);

How can i pass a second parameter like this?

Try with this:

TextBox tbText = (TextBox)DataList1.FindControl("TextBox1");
Session.Add("prm_quantity", tbText.Text);


I got an error message on this line:

Session.Add(

"prm_quantity", tbText.Text);

"NullReferenceException was unhandled by user code"
"Object reference not set to an instance of an object"


Hi,

It may be cache issue. Please look at this KB:

http://www.kbalertz.com/Feedback_831382.aspx

Good luck!

0 comments:

Post a Comment