Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to add item to databound combobox

Posted on 2007-11-16
4
Medium Priority
?
2,071 Views
Last Modified: 2013-11-27
To figure this out, I am going to create a simple example of what I am actually doing. I have a combobox that is bound to a table. There is a display member and a value member for each item. For example, the combobox collection might look like this:

John Doe
Joan Doe
Juda Doe

Each of these values has the value member of 1, 2, and 3 respectively.
After the names, I want there to be an option "Add User". When the user selects it, I want it to be assigned the next highest number, which would be 4 in this example.

Does anyone know how to do this?
0
Comment
Question by:tiehaze
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 26

Accepted Solution

by:
Alan Warren earned 2000 total points
ID: 20303935



I prefer to do it iusing my SQL with a union select, then handle the command argument on the postback when command argument is 0.

SELECT 0 AS 'MemberId', 'Add User' AS 'Member'
UNION ALL

SELECT DISTINCT ID AS 'MemberId', MemberName AS 'Member'
FROM            tblMembers

But you can also use the AppendDataBoundItems directive in your dropdownlist tag

<asp:DropDownList   ... AppendDatBoundItems="true">
<asp:ListItem Value="" Text="Add User" />
</asp:DropDownList>




hth

Alan ";0)

0
 
LVL 1

Expert Comment

by:Computer101
ID: 20520528
Forced accept.

Computer101
EE Admin
0
 

Expert Comment

by:harhsli_hbp
ID: 23275487
how can i acheive this same thing in C# for winforms. ??
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question