更新时间:2023-09-25 17:49:10
添加commandargument属性
使用OnCommand而不是OnClick
Add commandargument property
Use OnCommand instead of OnClick
<asp:imagebutton id="ImageButton1" oncommand="ImageButton1_Command" imageurl="~/images/apply.png" runat="server" commandargument="<%#Eval("ID") />
在ImageButton1_Command事件中,您获得ID
In ImageButton1_Command event you get ID
int ID = Convert.ToInt32(e.CommandArgument);
您可以将Id设置为Imagebutton的CommandArguement属性:
< asp :ImageButton ID =ImageButton1OnClick =ImageButton1_ClickImageUrl =〜/ images / apply.pngrunat =serverCommandArguement ='<%#Eval(Id)%>'/>
你可以在服务器端获得Id Imagebutton点击事件:
ImageButton ib =(ImageButton)Sender;
Int Id = int.Parse(ib.CommandArguement);
You can set Id to Imagebutton's CommandArguement Property:
<asp:ImageButton ID="ImageButton1" OnClick="ImageButton1_Click" ImageUrl="~/images/apply.png" runat="server" CommandArguement='<%# Eval("Id")%>' />
You can get Id on server side Imagebutton click event :
ImageButton ib = (ImageButton)Sender;
Int Id =int.Parse(ib.CommandArguement);
您可以使用GridView_RowCommand()
来完成。请点击以下链接此处。
谢谢
Hi,
You can do it using theGridView_RowCommand()
. Follow the following link here.
Thanks