HOW TO FIND CLICK EVENT OF BUTTON INSIDE FOOTR TEMPLATE IN GRIEDVIEW

Posted by Shanky11 under ASP.NET on 11/17/2012 | Points: 10 | Views : 3906 | Status : [Member] | Replies : 3
<asp:TemplateField>
<FooterTemplate>
<asp:Button ID="Button1" runat="server" Text="Insert" CommandName="add" />
</FooterTemplate>
</asp:TemplateField>

-----------QUESTION IS I HAVE TO FIND CLICK EVENT OF THIS BUTTON ; I HAVW WRITTEN THIS CODE
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if(e.CommandName=="add")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = GridView1.Rows[index];
ClientScript.RegisterStartupScript(Page.GetType(), "acknowledgement", "<script>alert('Record Added Successfully')</script>");

}
}




Responses

Posted by: Sandhyab on: 11/17/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

When Insert button is clicked the OnRowCommand event fires that execute the GridView1_RowCommand sever side method.

Thanks & Regards

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Srinivas673 on: 11/17/2012 [Member] Starter | Points: 25

Up
0
Down

if(e.CommandName=="add")
{
// Perform your insert operation here.
Like Your Footer Elements Details Can Be Find From GridView
DropDownList ddlFootortype = (DropDownList)grdCitationConfg.FooterRow.FindControl("ddlFootortype");
TextBox txtFootorDescription = (TextBox)grdCitationConfg.FooterRow.FindControl("txtFootorDescription");

Your Insert operation Based on footer Inpust.

}

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sheonarayan on: 11/17/2012 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
The similar article was written by me http://www.dotnetfunda.com/articles/article180.aspx. This not only clear your doubt but also details on how to insert record using GridView.

Hope this helps.

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response