Solved

How to add item to databound combobox

Posted on 2007-11-16
4
2,055 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 500 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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
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.

730 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