<asp:GridView ID="gv_data" runat="server" AutoGenerateColumns="False"
CellPadding="4" DataKeyNames="Id"
onselectedindexchanged="gv_data_SelectedIndexChanged">
<Columns>
<asp:TemplateField HeaderText="Vulnerability">
<ItemTemplate>
<%# Eval("Vulnerability")%>
</ItemTemplate>
<HeaderStyle CssClass="col2" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Description">
<ItemTemplate>
<%# Eval("Description")%>
</ItemTemplate>
<HeaderStyle CssClass="col2" />
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkselect" runat="server" OnClick="lnkselect_Click">View</asp:LinkButton>
</ItemTemplate>
<HeaderStyle CssClass="col2" />
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void lnkselect_Click(object sender, EventArgs e)
{
LinkButton lnkbtn = sender as LinkButton;
GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
int id = Convert.ToInt32(gv_data.DataKeys[gvrow.RowIndex].Value);
Session["id"] = id.ToString();
}
No comments:
Post a Comment