Link to home
Start Free TrialLog in
Avatar of Sheritlw
SheritlwFlag for United States of America

asked on

Linq to SQL Where ControlParameter for text in dropdownlist

Hi EE,

I have an asp page with 4 dropdownlists (DD) and a grid.  When a user selects a dropdown(DD)  it automatically fills the next  DD according to the selectedvalue.
Everything works fine when using the selected value, but on my last DD I have to take the text from the 3rd DD to filter the last DD.
For example, the 3rd DD has a list with CityID and  CityName, instead of filtering the last DD by CityID, I need to match the CityName field with the SalonCity field in the last DD.
How would I do this using Linq to SQL?
Thanks
<td>    
                         <asp:DropDownList ID="ddCity" Width="95%"  runat="server" AutoPostBack="True" 
                              DataSourceID="DSCities" DataTextField="CityName" 
                              DataValueField="CityLUID">
                         </asp:DropDownList>                                
                         <asp:LinqDataSource ID="DSCities" runat="server" 
                              ContextTypeName="SalonClassesDataContext" OrderBy="CityName" 
                              Select="new (CityLUID, CityName)" TableName="CitysLUs" 
                              Where="StateID == @StateID">
                              <WhereParameters>
                                   <asp:ControlParameter ControlID="ddState" Name="StateID" 
                                        PropertyName="SelectedValue" Type="Int32" />
                              </WhereParameters>
                         </asp:LinqDataSource>
                    </td>
                    <td>
                         <asp:DropDownList ID="ddSalonName"  Width="95%" runat="server" 
                              AutoPostBack="True" DataSourceID="DSSalonNames" DataTextField="SalonName" 
                              DataValueField="StylistID">
                         </asp:DropDownList>                                
                         <asp:LinqDataSource ID="DSSalonNames" runat="server" 
                              ContextTypeName="SalonClassesDataContext" OrderBy="SalonName" 
                              Select="new (StylistID, SalonName)" TableName="Stylists" 
                              Where="SalonCity == @CityName">
                              
                              <WhereParameters>
                                   <asp:ControlParameter ControlID="ddCity" Name="CityName" 
                                        PropertyName="SelectedItem" Type="String" />
                              </WhereParameters>
                         </asp:LinqDataSource>
                    </td>

Open in new window

Avatar of nmarun
nmarun
Flag of India image

Haven't tried this, but give this a shot:                                                                                                         PropertyName="SelectedItem.Text" Type="String" />                              Arun
not sure why it posted incorrectly. Second trial.Arun
<WhereParameters>
    <asp:ControlParameter ControlID="ddCity" Name="CityName" 
         PropertyName="SelectedItem" Type="String" />
</WhereParameters>

Open in new window

                PropertyName="SelectedItem.Text" Type="String" />
Ok.. my final answer is the first post.Arun
Avatar of Sheritlw

ASKER

Unfortunately It didn't work.
ASKER CERTIFIED SOLUTION
Avatar of nmarun
nmarun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I see, I would need to add some additional code to get that to work.

Thanks