【发布时间】:2016-07-29 14:56:46
【问题描述】:
我在asp:UpdatePanel 中有一个asp:GridView,它有一列asp:LinkButton 控件。
在行数据绑定事件中,LinkButton 获取分配的点击事件处理程序。
我已经尝试了所有我能找到的方法来连接点击,甚至没有任何事件触发。
我做错了吗?
aspx:
<asp:UpdatePanel ID="MainUpdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="lblTest" Text="test" runat="server" />
<asp:GridView ID="gvClientsArchive" runat="server" AllowSorting="true" DataSourceID="dsClients"
OnRowDataBound="gvClientsArchive_RowDataBound" SkinID="gvList"
AllowPaging="true" PageSize="25" Visible="false">
...
后面的代码:
protected void gvClientsArchive_RowDataBound(object sender, GridViewRowEventArgs e)
{
...
int company_id = int.Parse(drvRow["company_id"].ToString());
LinkButton lnkRestore = (LinkButton)e.Row.FindControl("lnkRestore");
lnkRestore.Click += new System.EventHandler(this.doRestore);
按钮处理程序代码:
private void doRestore(object sender, EventArgs e)
{
lblTest.Text = "restore clicked";
}
我也试过了:
protected void gvClientsArchive_RowDataBound(object sender, GridViewRowEventArgs e)
{
...
LinkButton lnkRestore = (LinkButton)e.Row.FindControl("lnkRestore");
lnkRestore.Click += delegate
{
lblTest.Text = "restore clicked";
};
【问题讨论】: