我目前有两个Web控件,一个是CheckBoxList,另一个是GridView。 GridView的数据配置在其查询中有一个参数,该参数与CheckBoxList中的选定值链接。然而,当这两个控件是在单独的内容标签,像这样:是否可以将不同内容标签中的控件用作参数?
<asp:Content ID="ListPanel" runat="server" ContentPlaceHolderID="LeftContent">
<h3>Pick Info Here</h3>
<asp:CheckBoxList ID="cbList1" runat="server"
DataSourceID="TestDataSource"
DataTextField="St" DataValueField="St" RepeatColumns="2">
</asp:CheckBoxList>
</asp:Content>
<asp:Content ID="ResultsPanel" runat="server" ContentPlaceHolderID="RightContent">
<asp:GridView ID="gView1" runat="server"
AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataSourceID="TestDS1">
<Columns>
...
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="TestDS1" runat="server"
...
SelectCommand="SELECT ST FROM [Table] where ST = ?">
<SelectParameters>
<asp:ControlParameter ControlID="cbList1" Name="?"
PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Content>
,当我把两个控件在同一<asp:Content>
标记它工作正常,但事情的System.InvalidOperationException: Could not find control 'cbList1' in ControlParameter '?'
错误调用分开。有没有办法保持控件分离,还是必须在同一个内容标签内?
是否有理由让他们在两个内容面板中? – TKTS 2011-04-18 21:24:08
达老板这么说。 – Nathanus 2011-04-18 21:59:33