问题描述
更新面板外面有一个按钮,按钮的点击事件绑定了网格视图。
网格视图位于更新面板内,网格视图内有一个链接按钮。
链接按钮导致完整回帖,我在网上查看并尝试了不同的方法,但到目前为止没有运气。
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<table>
<tr>
<td>
<asp:UpdatePanel ID="ContentUpdatePanel" runat="server">
<ContentTemplate>
<asp:GridView ID="gvMasterData" runat="server" AutoGenerateColumns="false" Width="200px" class="display">
<Columns>
<asp:TemplateField HeaderText="registration date" ItemStyle-Width="50">
<ItemTemplate>
<asp:Label ID="lblRegistrationDate" runat="server" Text='<%# Eval("registration_date") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="completed" ItemStyle-Width="50">
<ItemTemplate>
<asp:LinkButton Text='<%# Eval("completed") %>' ForeColor="Black" Font-Underline="false" runat="server" CommandName="Completed" CommandArgument="<%# Container.DataItemIndex %>" /> </ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="pending" ItemStyle-Width="50">
<ItemTemplate>
<asp:LinkButton ID="MarkAsCompleteButton" Text='<%# Eval("pending") %>' ForeColor="Black" Font-Underline="false" runat="server" CommandName="Pending" CommandArgument="<%# Container.DataItemIndex %>" /> </ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</table>
背后的代码
private void gvMasterData_RowDataBound(object sender,GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton lb = e.Row.FindControl("MarkAsCompleteButton") as LinkButton;
ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(lb);
}
}