用DropDownList动态选择表,并通过该表读出相应字段的联动菜单!。。。
flyso 2006-05-31 11:33:38 代码如下
一级菜单(选择表)
<asp:DropDownList ID="DropDownList2" runat="server" CssClass="DropDownList" AutoPostBack="True">
<asp:ListItem Value="table1" Selected="True">数据表1</asp:ListItem>
<asp:ListItem Value="table2">数据表2</asp:ListItem>
<asp:ListItem Value="table3">数据表3</asp:ListItem>
</asp:DropDownList>
二级菜单(通过上级菜单选择的表读出相关字段)
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2"
DataTextField="cname" DataValueField="cname" AutoPostBack="True" CssClass="DropDownList">
</asp:DropDownList>
数据源
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:yy960ConnectionString %>"
SelectCommand="SELECT DISTINCT [cname] FROM [table1] Where [tg]=0"></asp:SqlDataSource>
注:每个表都有相同字段cname
问:
怎么把数据源中的table1换成一级菜单选择的表(DropDownList2.SelectedValue),然后通过该表在
二级菜单(DropDownList1)读出相应的字段呢