更改JavaScript下拉列表的DataSourceId

时间:2015-09-30 07:28:01

标签: javascript asp.net

我是否可以根据javascript中的下拉选项更改下拉列表的DataSourceID我在下拉列表选择的基础上得到三个下拉值我想要更改SqlDataSource的数据源

<script type="text/javascript">
            function abc() {
            if (document.getElementById('type').value == "C") {

            }

           else if (document.getElementById('type').value == "G") {

            }
           else if (document.getElementById('type').value == "S") {

            }
        }
    </script>
        <asp:DropDownList ID="type" runat="server" onblur ="abc();">
            <asp:ListItem>C</asp:ListItem>
            <asp:ListItem>G</asp:ListItem>
            <asp:ListItem>S</asp:ListItem>
        </asp:DropDownList>
        <asp:SqlDataSource
          id="C"
          runat="server"
          DataSourceMode="DataReader"
          ConnectionString="<%$ConnectionStrings:ConnString%>"
          SelectCommand="select rtrim(customer) as customer,cust_id from a1_customer where isactive=1 order by customer">
      </asp:SqlDataSource>
      <asp:SqlDataSource
          id="G"
          runat="server"
          DataSourceMode="DataReader"
          ConnectionString="<%$ConnectionStrings:ConnString%>"
          SelectCommand="select rtrim(supplier) as supplier,sup_id from a1_supplier where isactive=1  order by supplier">
      </asp:SqlDataSource>
        <asp:SqlDataSource
          id="S"
          runat="server"
          DataSourceMode="DataReader"
          ConnectionString="<%$ConnectionStrings:ConnString%>"
          SelectCommand="select rtrim(title) as title ,acno,ac_type from a1_glcard where isactive=1 and levels=4 order by title">
      </asp:SqlDataSource>

    </td>
    <td>
    <asp:DropDownList ID="htitle" runat="server" DataSourceID="C" DataTextField="customer" DataValueField="cust_id"  Width="168px">

0 个答案:

没有答案