![](/img/trans.png)
[英]ASP.NET Gridview Dropdown Template Field Triggering SelectedIndexChanged on Gridview
[英]Image button on gridview not triggering asp.net
所以我有一個帶imagebutton的gridview,但事實是它永遠不會觸發。 我不知道為什么。 這是代碼。
<asp:GridView ID="GridView1" runat="server" Width="233px"
OnCommand="GridView1_RowCommand" onrowcommand="GridView1_RowCommand"
DataKeyNames="Nombre">
<Columns>
<asp:TemplateField HeaderText="" ItemStyle-Width="12%" ItemStyle-
HorizontalAlign="Center" >
<ItemTemplate>
<asp:ImageButton ID="lnkEditar" runat="server" CommandName="Edit"
ImageUrl="Imagenes/edit.png" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
以及后面的代碼:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Edit")
{
int index = Convert.ToInt32(e.CommandArgument);
Label1.Text = GridView1.Rows[index].Cells[2].ToString();
}
}
我調試了它,它從不觸發RowCommand事件。 感謝您的任何幫助!
嘗試按以下方式更改OnRowCommand
OnRowCommand="GridView1_RowCommand"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.