现在的位置: 首页 > 综合 > 正文

GridView相应模板列中的LinkButton按钮的事件

2012年06月23日 ⁄ 综合 ⁄ 共 461字 ⁄ 字号 评论关闭
1 定义LinkButton时需要填写CommandName属性(用来找到这个按钮的标识),也可填写CommandArgument属性(这个属性可是其他列的值)。
<ItemTemplate> 
<asp:LinkButton ID="lbtnNameDetail" runat="server" CommandName="open" CommandArgument='<%# Eval("ID") %>' Text='<%# Eval("Text") %>'> 
</asp:LinkButton> 
</ItemTemplate>

2 在gridview的RowCommand事件中相应对LinkButton的点击

protected void gv1_RowCommand(object sender, GridViewCommandEventArgs e) 

if (e.CommandName == "open"

string ID= e.CommandArgument.ToString; 
//your code 


抱歉!评论已关闭.