/ Published in: ASP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<asp:GridView ID="GridView1" runat="server" autogeneratecolumns="false"> <Columns> <asp:TemplateField HeaderText="TITLE"> <ItemTemplate> <asp:LinkButton ID="lnkTitle" runat="server" Text='<%#Bind("TITLE") %>' CommandArgument='<%#Eval("ID")%>' onclick="lnkTitle_Click"/> </ItemTemplate> </asp:TemplateField> <asp:boundfield datafield="TITLE" headertext="TITLE"/> <asp:boundfield datafield="DESCRIPTION" headertext="DESCRIPTION"/> <asp:boundfield datafield="OWNER" headertext="OWNER"/> <asp:TemplateField HeaderText="Enabled"> <ItemTemplate> <asp:CheckBox ID="chkEnabled" runat="server" Checked='<%# Eval("ENABLED") %>' /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> //////////////////////////////////Code Behind protected void lnkTitle_Click(object sender, EventArgs e) { LinkButton lnkTiltle = (LinkButton) sender; Int32 ID=Convert.ToInt32(lnkTiltle.CommandArgument.ToString()); }