0
<asp:ControlParameter ControlID="ddListPlayerPointSystems" Name="profileid" PropertyName="SelectedValue" />
            <asp:ControlParameter ControlID="ddListCmty" Name="cmty" PropertyName="SelectedValue" />
            <asp:ControlParameter ControlID="ctl00$MainContent$TabContainer1$TabPanel1$FormView3$pointsTextBox" Name="InsertPts" PropertyName="Text" Type="Decimal" />

我无法理解为什么在第一个控制参数中我可以调用下拉框 id 而不是文本框 id,即 pointsTextBox。我正在使用带有多个面板的 asp ajax 选项卡容器的母版页。如果我取下“ctl00$MainContent$TabContainer1$TabPanel1$FormView3$”,我会得到一个未找到的控件,但我不知道为什么这适用于其他两个控制参数

编辑 所以我找到了解决我的问题的方法。感谢@TheGeekYouNeed 和@JamesJ,我明白为什么我需要为那个特定的文本框提供更长的路径名(drop 在 tabcontainer 之外,所以直接名称有效)。但我发现,由于我是通过 '<%# Bind("name", "{0:n}") %>' 分配该文本框的值,因此我可以只使用 asp:Parameter 而不是 ControlParameter像这样:

"<asp:Parameter Name="name" Type="String" />"

问题是我不太明白这一切是如何运作的。

4

1 回答 1

0

pointsTextBox 的 ControlID 在服务器端不是 'ct100$MainContent$TabContainer..etc...。

在后面的代码中设置 COntrolID,这样您就可以使用 FindControl("pointsTextBox") 来获取对文本框控件的引用。

您可以执行以下操作:

TextBox t = this.FindControl("pointsTextBox") as TextBox;
if(t != null)
{
    ddListPlayerPOintSystems.Add(new { COntrolID = t, Name = "InsertPts", PropertyName="Text", Type="Decimal"});
}

我还没有测试过,所以我并不是说代码是完美的,但是这里说明了你需要遵循的方法。

于 2012-04-18T18:24:05.830 回答