473,398 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

AppendDataBoundItems giving dups

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
Jun 25 '07 #1
2 1660
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???

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://iWritePro.com

"David C" <dl*****@lifetimeinc.comwrote in message
news:O%****************@TK2MSFTNGP03.phx.gbl...
>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

Jun 25 '07 #2
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
"David Wier" <da*******@davidwier.nospam.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
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???

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://iWritePro.com

"David C" <dl*****@lifetimeinc.comwrote in message
news:O%****************@TK2MSFTNGP03.phx.gbl...
>>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


Jun 25 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: KEVIN97810 | last post by:
Hello to all, I read data from SQL and populate a table. Howerver, there are dups that I need to prevent into my table. The dups only are in these two fields. How do you prevent this in the...
12
by: prasi | last post by:
hi all, I have executed the following program, I was expecting some errors in the program but it didn't give any ERRORS!!!!!!!!!!!!!!!!!!!!!!!!!!! please can anybody explain me ?...
0
by: sandeep pandit via .NET 247 | last post by:
hello sir, i read your article on URL rewriting in asp.net on msdn.i have also used the same in my project.URL rewriting is working fine in our LAN and on our configured IP but problem is that...
5
by: washoetech | last post by:
Hello, I have tried to run my ASP.NET 2.0 application from IIS and I get a page not found error. When I debug from within Visual Studio.NET 2005 my application works fine. Any ideas? ...
2
by: Just Me | last post by:
I've been checking the doc for the combobox to see it there is some way I can set it up to be sorted (I found that) and to have no duplicate entries. I don't see any way to avoid dups unless...
9
by: Rhino | last post by:
How hard (and desireable) would it be to give the user certain choices when it comes to printing web pages? The pages on my site use colours and pictures and contain an imbedded menu, among...
0
by: MattBell | last post by:
I have a drop down list control which I want to have automatically add a null item to. So I extended DropDownList and tried to have it add an item to the control on the performdatabind function. ...
2
by: Sridhar | last post by:
Hi, I have a web form where it has a <input type=file id=file1> control. I have an Upload button to upload the file. WHen I click on browse and select one file, it is showing the full file path...
0
by: charmeda103 | last post by:
when i run my program it runs with no erorrs but the output screen is giving me strange results here is whats its giving me: CONFERENCE OVERALL RANK TEAM W-L % WINS MARGIN W-L ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.