c# - Retrieving the ID of the column and storing it in Session when clicked on Hyperlinkfield -


i have gridview populated sql table has 2 fields: id , subjects.

subject on form of hyperlinkfield. store id of column in session so, when click hyperlinkfield able use on webform. have used databound doesn't seem work. using c#.

thank in advance.

p.s: first question, sorry inconvenience. beginner in programming.

use button field of link type in grid view , set datatextfield subject wanted display. handle rowcommand event of grid view , can id , assign session variables.

<asp:gridview onrowcommand="grid1_rowcommand" runat="server" id="grid1">         <columns>             <asp:boundfield datafield="id" headertext="id" />             <asp:buttonfield buttontype="link" datatextfield="subject" />         </columns>     </asp:gridview> 

and code behind :

protected void grid1_rowcommand(object sender, gridviewcommandeventargs e)     {        int rowindex = convert.toint32(e.commandargument);        string str = grid1.rows[rowindex].cells[0].text;        session["subject"] = str;     } 

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -