FindControl() 和嵌套控件

发布于 2025-01-07 10:20:57 字数 682 浏览 1 评论 0原文

我有这样的 ASP 代码:

 <ext:GridPanel ID="grid">
                <ColumnModel runat="server">
                    <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("grdResourceState.ColumnModel.Columns"); // this is a null

我该怎么做才能使 FindControl 能够搜索控件子项?

I have this ASP code:

 <ext:GridPanel ID="grid">
                <ColumnModel runat="server">
                    <Columns>
                        <ext:RowNumbererColumn />
                        <ext:Column Align="Center" ColumnID="Type">
                        </ext:Column>
                    // closing tags

I want to get the columns object. I'm trying this:

var typeCol= this.grdResourceState.ColumnModel.Columns.Where(column => column.ColumnID == "Type"); // this works
var typeColRef= FindControl("grdResourceState.ColumnModel.Columns"); // this is a null

What do I do to make FindControl be able to search control children?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七颜 2025-01-14 10:20:57

您应该为 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");

这里有有关 FindControl 的更多信息方法

You should assign an id to the ColumnModel control and then retrieve if. Once you got it you can access the children controls:

<ext:GridPanel ID="grid">
                <ColumnModel runat="server" id="someId">
                    <Columns>
                        <ext:RowNumbererColumn />
                        <ext:Column Align="Center" ColumnID="Type">
                        </ext:Column>
                    // closing tags

Then:

var typeCol= this.grdResourceState.ColumnModel.Columns.Where(column => column.ColumnID == "Type"); // this works
var typeColRef= FindControl("someId");

Here's more info on the FindControl method

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文