I have a drop down list that pulls a list of last names. The problem is some people have the same last name and for some reason it always shows one name. The drop down list is connected to a sql server and here is the code for the drop down list:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
DataSourceID="SqlDataSource3" DataTextField="lName" DataValueField="lName"
AppendDataBoundItems="True"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Value="0">Select</asp:ListItem>
</asp:DropDownList>
and here is the SqlDataSource:
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:TestDBConnectionString1 %>"
SelectCommand="SELECT DISTINCT [lName] FROM [CoaTest]"></asp:SqlDataSource>
Thank you in advance!
You’re using
SELECT DISTINCTin your sql. When usingDISTINCT, it will load all of the results from your query, and then select the distinct values. So in your case, if you have these last names returned as your result setIt will select the distinct values from that, and ultimately return