我有 2 dropdownlist
,它们绑定到 aSQLDataSource
并且值2nd dropdownlist
基于 1st dropdownlist
。问题是默认情况下dropdownlist
显示实际值。我把初始值放在 dpsem 中,所以它工作正常。但是当我做同样的dpsubj dropdownlist
事情时,它也会显示以前的值。
如果我选择 dpsem--4 那么 dpsubj 应该是 A,B,C,如果我选择 dpsem--6 那么 dpsubj 应该是 D,E,F。但它显示 A,B,C,D,E,F...
我知道这是与 Autopostback 相关的问题...
<asp:DropDownList ID="dpsem" runat="server" Height="28px"
Width="99px" AutoPostBack="True" DataSourceID="selectsemester"
DataTextField="sem_no" DataValueField="sem_no" AppendDataBoundItems="true">
<asp:ListItem Selected="True" Value="0">-select</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="dpsubj" runat="server" Height="28px"
Width="99px" AutoPostBack="True" DataSourceID="Selectscode"
DataTextField="scode" DataValueField="scode" AppendDataBoundItems="true">
<asp:ListItem Selected="True" Value="0">-select</asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="Selectscode" runat="server"
ConnectionString="<%$ ConnectionStrings:AttendenceManagementConnectionString %>"
SelectCommand="SELECT DISTINCT [scode] FROM [Semester_Wise_Subject] WHERE (([branch_name] = @branch_name) AND ([sem_no] = @sem_no))">
<SelectParameters>
<asp:ControlParameter ControlID="lbdept" DefaultValue="IT" Name="branch_name"
PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="dpsem" DefaultValue="6" Name="sem_no"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="selectsemester" runat="server"
ConnectionString="<%$ ConnectionStrings:AttendenceManagementConnectionString %>"
SelectCommand="SELECT DISTINCT [sem_no] FROM [Batch_year]">
</asp:SqlDataSource>