Translate

> | > Add Custom Button in Gridview

Add Custom Button in Gridview

Posted on Saturday, February 4, 2012 | No Comments

Add this code in grid columns section
<asp:TemplateField>
                        <ItemTemplate>
                            <asp:Button ID="btnPay" runat="server" Text="Pay" OnClick="btnPay_Click" />
                        </ItemTemplate>
                    </asp:TemplateField>


Then add following code in CS file

DataControlFieldCell dcf = ((DataControlFieldCell)((Button)sender).Parent);
 GridViewRow gvr = dcf.Parent as GridViewRow;
lblMsg.Text = gvr.Cells[0].Text;

Leave a Reply

Powered by Blogger.