1 定义LinkButton时需要填写CommandName属性(用来找到这个按钮的标识),也可填写CommandArgument属性(这个属性可是其他列的值)。
GridView相应模板列中的LinkButton按钮的事件<ItemTemplate> 
GridView相应模板列中的LinkButton按钮的事件
<asp:LinkButton ID="lbtnNameDetail" runat="server" CommandName="open" CommandArgument='<%# Eval("ID") %>' Text='<%# Eval("Text") %>'> 
GridView相应模板列中的LinkButton按钮的事件
</asp:LinkButton> 
GridView相应模板列中的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 


相关文章: