Note that there are some explanatory texts on larger screens.

plurals
  1. POPass a gridview column value to a session using javascript
    primarykey
    data
    text
    <p>I have a gridview that contains a list of products. What i am trying to do is using the ItemTemplate is pass the ProductID of the selected item using an Onclick event to a session so i can then lookup that session on another page to avoid having the ProductID shown in the URL.</p> <pre><code> &lt;asp:GridView ID="GVProducts" runat="server" onselectedindexchanged="GVProducts_SelectedIndexChanged"&gt; &lt;Columns&gt; &lt;asp:ImageField DataImageUrlField="FileName" DataImageUrlFormatString="Images/{0}" HeaderText="Image"&gt; &lt;ControlStyle Height="80px" Width="80px" /&gt; &lt;/asp:ImageField&gt; &lt;asp:TemplateField HeaderText="Title" SortExpression="ProductID" &gt; &lt;ItemTemplate&gt; &lt;a onclick="javascript:function setSessionVariable(&lt;%#Eval("ProductID")%&gt;)" href="ProductDetail.aspx"&gt;&lt;%#Eval("Title")%&gt;&lt;/a&gt; &lt;/ItemTemplate&gt;&lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;FooterStyle BackColor="#99CCCC" ForeColor="#003399" /&gt; &lt;HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" /&gt; &lt;PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" /&gt; &lt;RowStyle BackColor="White" ForeColor="#003399" /&gt; &lt;SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" /&gt; &lt;SortedAscendingCellStyle BackColor="#EDF6F6" /&gt; &lt;SortedAscendingHeaderStyle BackColor="#0D4AC4" /&gt; &lt;SortedDescendingCellStyle BackColor="#D6DFDF" /&gt; &lt;SortedDescendingHeaderStyle BackColor="#002876" /&gt; &lt;/asp:GridView&gt; </code></pre> <p>Hopefully it is something simple as i am just starting out with javascript but i cant seem to get it to pass to the session.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload