C# ASP.Net网格视图编辑-在多页网格视图上查找控件
我有一个gridview,在我的aspx文件的一个单元格中有一个文本框 单击行中的编辑链接后,我可以通过以下方式在rowdatabound事件中以编程方式获取控件:C# ASP.Net网格视图编辑-在多页网格视图上查找控件,c#,asp.net,.net,gridview,row,C#,Asp.net,.net,Gridview,Row,我有一个gridview,在我的aspx文件的一个单元格中有一个文本框 单击行中的编辑链接后,我可以通过以下方式在rowdatabound事件中以编程方式获取控件: e.Row.FindControl("controlPlaceholder"); 使用编辑事件中的编辑索引也可以工作 但是,该控件仅在gridview的第一页上启用。在任何其他页面上,FindControl返回null 这可能是什么原因?这个问题有没有潜在的解决方案?我一直在寻找解决方案,但没有找到有这个特殊问题的人 标记: &l
e.Row.FindControl("controlPlaceholder");
使用编辑事件中的编辑索引也可以工作
但是,该控件仅在gridview的第一页上启用。在任何其他页面上,FindControl返回null
这可能是什么原因?这个问题有没有潜在的解决方案?我一直在寻找解决方案,但没有找到有这个特殊问题的人
标记:
<asp:Panel ID="pnlAccountAssignment" runat="server" CssClass="clsDataPanel" meta:resourcekey="pnlAccountAssignmentResource1">
<asp:GridView ID="gvAccountAssignment" runat="server" AutoGenerateColumns="False"
AllowPaging="true" PageSize="25" OnRowDataBound="gvAccountAssignment_RowDataBound"
OnRowCancelingEdit="gvAccountAssignment_RowCancelingEdit" OnRowEditing="gvAccountAssignment_RowEditing"
OnRowUpdating="gvAccountAssignment_RowUpdating" OnPageIndexChanging="gvAccountAssignment_PageIndexChanging"
OnSorting="gvAccountAssignment_Sorting" AllowSorting="True" meta:resourcekey="gvAccountAssignmentResource1">
<RowStyle BackColor="White" ForeColor="Black" />
<HeaderStyle CssClass="clsGrayBkgCell" HorizontalAlign="Center" VerticalAlign="Bottom" />
<Columns>
...Other Columns...
<asp:TemplateField meta:resourcekey="TemplateFieldResource8">
<ItemStyle CssClass="clsNumber" HorizontalAlign="Left" VerticalAlign="Top" />
<EditItemTemplate>
<asp:TextBox ID="column13PlaceHolder" runat="server" CssClass="clsNormalLabel">
</asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblprevMonth" runat="server" CssClass="clsNormalLabel"></asp:Label>
</ItemTemplate>
<HeaderTemplate>
<asp:LinkButton runat="server" ID="hypSortGLBal" OnClick="hypSortGLBal_Click"></asp:LinkButton>
</HeaderTemplate>
</asp:TemplateField>
...Other Columns...
</Columns>
<PagerStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:GridView>
<asp:HiddenField ID="hdnPrepPopulated" runat="server" />
</asp:Panel>
你真的需要发布一些代码/html。一般来说,当通常从gridview中选择edit时,您不需要启用/禁用控件进行编辑,因为它会将控件置于编辑模式,并使数据输入变得相对简单。很抱歉,单击edit按钮时会启用该控件,但仅在第一页上启用。在任何其他页面上,它在编辑模式下未启用,FindControl无法找到它。您可以从aspx页面发布gridview标记吗?