I face the following problem :
when I set my sessions in my aspx according to my requirements like this :
<Columns>
<asp:TemplateField ItemStyle-Width="10px">
<ItemTemplate>
<a id="btnShowPopup5" runat="server" class="thickbox" href='<%#"PopUp.aspx?AR=2"+"&TBiframe=true&height=530&width=750"%>'
<asp:Image ID="Image23" runat="server" ToolTip="Back" ImageUrl="Images/cross.png" /></a>
<asp:HiddenField ID="HDN_TaskCode" Value='<%# Session["s_TaskCode"] = DataBinder.Eval(Container.DataItem, "TaskCode") %>'
runat="server" />
I note that : Session["s_TaskCode"] was set always with the first row task code value in the gridview!!
and this’s not what i want.
I want to set my sessions according to the rows .
say my gridview has two rows :
- The first task_code value is 7
- The second task_code value is 10
I want to set the session with the correct value according to the hyper link i click on .
Like data keys.
Note : i want to set my sessions in the .aspx not .cs .
You have using only one Session Variable (
Session["s_TaskCode"]) in your code. So, how can you retain multiple values in it. It will always contain the value last written to it.To store row-wise values in session, you have to do something like:
Session["s_TaskCode" + rowIndex]Here, rowIndex is <%# Container.DataItemIndex %>
So you can use like:
<%# Session["s_TaskCode" + Container.DataItemIndex] %>Edit:
Instead of session, why don’t you pass the value of TaskCode in the ‘btnShowPopup5’ href url QueryString parameters: