Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am having a gridview and I am editing the data in it using ajax modal pop up extender.
When I am clicking the edit button the event is not getting fired the first time.
The event is getting fired only on the 2nd click.

This is my aspx code.
<asp:TemplateField HeaderText="Edit">
<itemtemplate>
<asp:ImageButton ID="imgbtn" ImageUrl="~/image/Edit.jpg" runat="server" Width="25"
Height="25" OnClick="imgbtn_Click" CausesValidation="false" />



This is code for Modal Popup

<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnShowPopup"
PopupControlID="pnlpopup" CancelControlID="btnCancel" BackgroundCssClass="modalBackground">

<asp:Panel ID="pnlpopup" runat="server" BackColor="White" Height="269px" Width="400px"
Style="display: none">

cellpadding="0" cellspacing="0">
<tr id="tr1" runat="server" visible="false">

align="center">
Fuel Master
UserId:
<asp:Label ID="lblID" runat="server">
Username:
<asp:TextBox ID="txtfname" runat="server" />
<asp:Button ID="btnUpdate" CommandName="Update" runat="server" Text="Update" OnClick="btnUpdate_Click" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />



This is my aspx.cs code event for the button click.

protected void imgbtn_Click(object sender, ImageClickEventArgs e)
{
ImageButton btndetails = sender as ImageButton;
GridViewRow gvrow = (GridViewRow)btndetails.NamingContainer;
lblID.Text = gvdetails.DataKeys[gvrow.RowIndex].Value.ToString();
txtfname.Text = gvrow.Cells[1].Text;
this.ModalPopupExtender1.Show();
}

Please help me to fix this issue?
Posted

1 solution

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900