AppendDataBoundItems giving dups

D

David C

I have a DropdownList tied to an SqlDataSource (table) used to select a
single company. I also want 2 options on this list, one for no selection
and one for firing an add new company process. However, when I add 2 manual
items, I get duplicates from the company table for each record in that
table. How can I get around this? Below is the control info.

<asp:DropDownList ID="ddlCompanyID" runat="server"
DataSourceID="SqlCompanies"

DataTextField="CompanyName" DataValueField="CompanyID"
AppendDataBoundItems="true">

<asp:ListItem Value="0" Text="--None--" />

<asp:ListItem Value="-1" Text="--<New Company>--" />

</asp:DropDownList>


Thanks.
David
 
D

David Wier

Could you explain in a little more detail, exactly what's happening?
when you talk about the duplicates, you're explaining something you haven't
referred to previously

Are you adding an item to the ddl, or adding something from the ddl to
somewhere else???
 
D

David C

Sure. For example, I have 2 companies as follows:
CompanyID = 1
CompanyName = Acme Electronics

CompanyID = 2
CompanyName = Digital Services

When I pull down the drop down list it shows the above companies twice. I
think it might have something to do with the fact that I have 2 listitems
added.

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top