我有这个ASP代码:
<ext:GridPanel ID="grid">
<ColumnModel runat="server">
<Columns>
<ext:RowNumbererColumn />
<ext:Column Align="Center" ColumnID="Type">
</ext:Column>
// closing tags
我想获取columns对象。我正在尝试这个:
var typeCol= this.grdResourceState.ColumnModel.Columns.Where(column => column.ColumnID == "Type"); // this works
var typeColRef= FindControl("grdResourceState.ColumnModel.Columns"); // this is a null
如何让FindControl
能够搜索控制孩子?
答案 0 :(得分:0)
您应该为 ColumnModel 控件分配一个ID,然后检索if。一旦你得到它,你可以访问儿童控件:
<ext:GridPanel ID="grid">
<ColumnModel runat="server" id="someId">
<Columns>
<ext:RowNumbererColumn />
<ext:Column Align="Center" ColumnID="Type">
</ext:Column>
// closing tags
然后:
var typeCol= this.grdResourceState.ColumnModel.Columns.Where(column => column.ColumnID == "Type"); // this works
var typeColRef= FindControl("someId");