Setting following Property in Gridview
BackColor="#EEEEEE" Width="100%" AutoGenerateColumns="False">
<asp:TemplateField HeaderText="Edit" ItemStyle-CssClass="hs1" HeaderStyle-CssClass="header-center">
<ItemTemplate>
<asp:LinkButton ID="linkEdit" runat="server" Text="Edit" OnClick="linkEdit_Click"/>
</ItemTemplate>
</asp:TemplateField>
Add label with Database Column
<asp:TemplateField HeaderText="Paper ID" ItemStyle-CssClass="hs1" HeaderStyle-CssClass="header-center">
<ItemTemplate>
<asp:Label ID="LBLID" runat="server" Text='<%# Eval("ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
C# Code Link button Event
protected void paybtn_Click(object sender, EventArgs e)
{
GridViewRow clickedRow = ((LinkButton)sender).NamingContainer as GridViewRow;
Label lblID = (Label)clickedRow.FindControl("LBLID");
lblJ_ID.Text = lblID.Text;
Session["paperid"] = lblJ_ID.Text;
Response.Redirect("payment1.aspx");
}
No comments:
Post a Comment