Click here to Skip to main content
15,914,010 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a datalist in page name "Product Category" and datalist in page name "Product"
and i want to get the value of the label in datalist in page "product Category" to save it in the session to get the product of the category in page product
Thank you...

OP's additional information added
i tried this method but it doesn't work
C#
protected void DataList1_SelectedIndexChanged(object sender, EventArgs e)
{
  Label lblLabel1 = (Label)DataList1.Items[DataList1.SelectedIndex].FindControl("Label1");
  Session["nam"] = lblLabel1.Text;
}
Posted
Updated 25-Nov-12 7:58am
v2
Comments
Nelek 25-Nov-12 7:21am    
amr mustafa 25-Nov-12 8:29am    
i tried this method but it doesn't work
protected void DataList1_SelectedIndexChanged(object sender, EventArgs e)
{
Label lblLabel1 = (Label)DataList1.Items[DataList1.SelectedIndex].FindControl("Label1");
Session["nam"] = lblLabel1.Text;
}
Nelek 25-Nov-12 14:00pm    
Only with "it doesn't work" is difficult to see what happens.

Have you tried with the debugger, setting a stop point and running it step by step?What kind of error are you getting?
amr mustafa 25-Nov-12 14:06pm    
yes the error is "Object reference not set to an instance of an object."
the session doesn't create the object
Nelek 25-Nov-12 14:12pm    
Is "Session" an array?

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900