Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27358

dropdownlist duplicates when refilling dataset

$
0
0
I have a dropdown list that fills correctly when I first create the datatable with the first pull of data for a locatioin.
When I go back and choose a different location, it still is holding the original data from the first pull.
Here is the dropdownlist definition:

Code:

<asp:DropDownList ID="ddlSalesPersonSearch"
                                    runat="server" AppendDataBoundItems="True" BackColor="#F7B432"
                                    CssClass="ColHeading" Width="150px" AutoPostBack="True">
                                    <asp:ListItem Value="0">ALL</asp:ListItem>
                                </asp:DropDownList>

Here is the code that creates the table.
Code:

If Session("Loc_No") <> Nothing Then
            If Session("usrIsAdmin") = "True" Then
                'strFilter = ""
                strFilter2 = "locations  like '%" & Session("Loc_No") & "%'"
            ElseIf Session("usrIsfhAdmin") = "True" Then
                strFilter2 = "locations  like '%" & Session("Loc_No") & "%'"
            Else
                strFilter2 = "username = '" & Session("usrName") & "'"
            End If
        End If

        strSQL = "select id from NavCare_Security where " & strFilter2 & " order by id"

        Dim da As New SqlDataAdapter(strSQL, MyConn)
        Dim ds As New DataSet
        ds.Dispose()
        da.Fill(ds, "SalesPerson")
        da.Dispose()


        With ddlSalesPersonSearch
            .DataSource = ds.Tables("SalesPerson")
            .DataMember = "id"
            .DataTextField = "id"
            .SelectedIndex = 0
        End With
        ddlSalesPersonSearch.DataBind()

I am not sure what needs to change.

Any help would be greatly appreciated.
Eddi Rae

Viewing all articles
Browse latest Browse all 27358

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>