none
How to filter a combo box with a value selected from another combo box RRS feed

  • Question

  • Dear All,

    I am coding a web based program using ASP.NET C# 2010.  I have combo box Account that linked with linqdatasource named LinqDSAccount and I have another combo box SubAccount that linked with linqdatasource named LinqDSSubAccount. The question is when user select account eg. Finance, and then when user click combo box SubAccount, the combo box SubAccount will only display data subaccount for finance only. How to make a filter in combo box SubAccount with the value selected from combo box Account.  Does anyone can help me ?

    Thank a lot before.

    Regards,

    Sentoso

    Tuesday, March 19, 2013 12:29 PM

Answers

  • You will need to use a query with a parametrized WHERE clause in the LinqDSSubAccount (see http://msdn.microsoft.com/en-us/library/bb547113.aspx). Something like:

    <asp:LinqDataSource 
        ContextTypeName="ExampleDataContext" 
        TableName="SubAccount" 
        AutoGenerateWhereClause="true"
        ID="LinqSDSSubAccount" 
        runat="server">
      <WhereParameters>
        <asp:ControlParameter 
          Name="Category" 
          ControlID="Account" 
          Type="String" />
      </WhereParameters>
    </asp:LinqDataSource>
    

    Tuesday, March 19, 2013 12:51 PM