Click here to Skip to main content
12,394,769 members (71,988 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
Can anyone solve this. Click event of Image button inside gridview is not firing for first time. But firing for second time. Below is my code. Thanks in advance.

 protected void Page_Load(object sender, EventArgs e)
 {
   // some code //
 }
 protected void Page_PreRenderComplete(object sender, EventArgs e)
 {
   // some code //
 }
 protected void grid1_RowCommand(object sender, GridViewCommandEventArgs e)
 {
    if (e.CommandName == "Edit")
    {
      // some code //
    }
 }
 protected void grid1_RowEditing(object sender, GridViewEditEventArgs e)
 {
 }
 
Design :
 
<asp:GridView ID="grid1" runat="server" AllowSorting="True" CssClass="GridStyle"                                                                              AutoGenerateColumns="False" OnRowCommand="grid1_RowCommand" DataKeyNames="ID" OnRowEditing="grid1_RowEditing" OnRowDeleting="grid1_RowDeleting">
   <Columns>
       <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID" Visible="false" />                    
       <asp:BoundField DataField="FirstName" HeaderText="First Name" ReadOnly="True" />
       <asp:BoundField DataField="LastName" HeaderText="Last Name" ReadOnly="True"  />
       <asp:TemplateField HeaderText="Edit">
           <ItemTemplate>
            <asp:ImageButton ID="imgEdit" ImageUrl="~/Images/edit.jpg" ToolTip="Edit Record"                  CommandName="Edit" runat="server" />
           </ItemTemplate>
Posted 28-Mar-13 1:02am
Comments
Member 8112455 28-Mar-13 7:57am
   
Have you used any validation controls like required field validator in your page?
navinKNR 28-Mar-13 10:03am
   
No

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 28 Mar 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100