0
Вот код, когда я пытаюсь сгореть случай в браузере он не стрелялИзображение кнопки OnClick событие не стрельбы
<asp:Panel ID="StateDistrictGrid_pnl" runat="server">
<asp:GridView ID="User_grd" runat="server" DataKeyNames="VoterID" AutoGenerateColumns="False" AllowPaging="True">
<Columns>
<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<asp:ImageButton ID="Img_btn" ImageUrl="~/Images/52105-200.png" OnClick="Img_btn_Click" Height="20px" Width="30px" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ID" Visible="false" />
<asp:BoundField DataField="VoterName" HeaderText="Voter Name" SortExpression="VoterName" />
<asp:BoundField DataField="StateName" HeaderText="State Name" SortExpression="StateName" />
<asp:BoundField DataField="DistrictName" HeaderText="District Name" SortExpression="DistrictName" />
</Columns>
</asp:GridView>
<asp:Label ID="Lbl_Result" runat="server">
<asp:Button ID="BtnShowPopup" runat="server" Text="Edit" />
<asp:ModalPopupExtender ID="Show_mpe" runat="server" TargetControlID="BtnShowPopup" PopupControlID="PopUp_Pnl" CancelControlID="Btn_Cancel" BackgroundCssClass="textbox_radius"></asp:ModalPopupExtender>
<asp:Panel ID="PopUp_Pnl" runat="server" style = "display:none">
<asp:Label Font-Bold = "true" ID = "Details_lbl" runat = "server" Text = "Voter Details" ></asp:Label>
<br />
<table align = "center">
<tr>
<td>
<asp:Label ID = "ID_lbl" runat = "server" Text = "Voter ID" ></asp:Label>
</td>
<td>
<asp:TextBox ID="VoterID_txt" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID = "Voter_lbl" runat = "server" Text = "Voter Name" ></asp:Label>
</td>
<td>
<asp:TextBox ID="VoterName_txt" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID = "Statepnl_lbl" runat = "server" Text = "State Name" ></asp:Label>
</td>
<td>
<asp:TextBox ID="State_txt" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID = "Districtpnl_lbl" runat = "server" Text = "District Name" ></asp:Label>
</td>
<td>
<asp:TextBox ID="District_txt" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnSave" runat="server" Text="Save" />
</td>
<td>
<asp:Button ID="Btn_Cancel" runat="server" Text="Cancel" />
</td>
</tr>
</table>
</asp:Panel>
</asp:Label>
</asp:Panel>
и код Бэкэнд так: является тир любой проблемы в в моем коде, пожалуйста, помогите спасибо
protected void Img_btn_Click(object sender, ImageClickEventArgs e)
{
ImageButton Bt = sender as ImageButton;
GridViewRow GVRow = (GridViewRow)Bt.NamingContainer;
ID_lbl.Text = User_grd.DataKeys[GVRow.RowIndex].Value.ToString();
VoterName_txt.Text = GVRow.Cells[2].Text;
State_txt.Text = GVRow.Cells[3].Text;
District_txt.Text = GVRow.Cells[4].Text;
}
, но когда я запускаю это событие не Fired..What проблемы?
попробуйте поставить 'alert' и проверить ... – BNN
Вы не можете использовать обычное событие OnClick на кнопке внутри шаблона GridView. Вам нужно подписаться на событие OnRowCommand вашего GridView. Вы даете своему ImageButton уникальное имя CommandName и проверяете это имя в событии RowCommand. Посмотрите, как это сделать здесь http://www.codeproject.com/Tips/564619/Example-of-gridview-rowcommand-on-Button-Click – Scotty
Вы разместили свой код внутри панели обновления? –