We help IT Professionals succeed at work.

asp.net: how can I combine the results of this query into one DDL

westdh
westdh used Ask the Experts™
on
  <asp:SqlDataSource ID="dsPopulateExt3" runat="server" ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>"
                SelectCommand="SELECT DISTINCT Ext3
      ,[State]
      ,[City]
      ,[Ext2]    
  FROM [trip4usdnn].[trip4usdnn].[Netism_MapExtreme_Locations] where state = 'OR' or state = 'WA' "></asp:SqlDataSource>

--------------------------------------------- this ddl is populate only with ext3,
i would like it  to have the values of all four fields
Ext3  ,State , City  ,Ext2


<asp:DropDownList ID="ddlExt3" DataSourceID="dsPopulateExt3" AutoPostBack="true"
                            DataValueField="Ext3" runat="server" Width="110px" Font-Size="11px" AppendDataBoundItems="true">
                            <asp:ListItem Text="All" Value="%"></asp:ListItem>
           
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Daniel Van Der WerkenIndependent Consultant

Commented:
Can you do this?

  <asp:SqlDataSource ID="dsPopulateExt3" runat="server" ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>"
                SelectCommand="SELECT DISTINCT Ext3 + ' ' + [State] + ' ' + [City] + ' ' + [Ext2]    
  FROM [trip4usdnn].[trip4usdnn].[Netism_MapExtreme_Locations] where state = 'OR' or state = 'WA' "></asp:SqlDataSource>

Author

Commented:
      SELECT DISTINCT Ext3 + ' ' + State + ' ' + City + ' ' + Ext2  
  FROM [trip4usdnn].[trip4usdnn].[Netism_MapExtreme_Locations] where state = 'OR' or state = 'WA'

I get an error on Ext3

DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Ext3'
Independent Consultant
Commented:
Oh.  I see.

Try this:

<asp:SqlDataSource ID="dsPopulateExt3" runat="server" ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>"
                SelectCommand="SELECT DISTINCT Ext3 + ' ' + [State] + ' ' + [City] + ' ' + [Ext2]  AS MyData
  FROM [trip4usdnn].[trip4usdnn].[Netism_MapExtreme_Locations] where state = 'OR' or state = 'WA' "></asp:SqlDataSource>

<asp:DropDownList ID="ddlExt3" DataSourceID="dsPopulateExt3" AutoPostBack="true"
                            DataValueField="MyData" runat="server" Width="110px" Font-Size="11px" AppendDataBoundItems="true">
                            <asp:ListItem Text="All" Value="%"></asp:ListItem>

Author

Commented:
Thanks that did it.