473,387 Members | 1,766 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,387 software developers and data experts.

DropDownList Question

My application has a series of dropdownlists with AutoPostBack set to
True and IndexChanged handlers as well. All of the dropdownlists are
bound and dynamically populated.

Is there a way to manually add an entry to a dropdownlist that is
bound? The reason I ask is because if the first item is the one the
user wants to select it is not able to postback since it is already
selected.

Nov 19 '05 #1
4 966
Hi Will,

You could just add a new item into the underlying data source.

For example, if you are using a datatable as the datasource, add a new row
to it with the topmost value to display, and then bind to the drop down.

You could also set up client side scripts so that a client-side validation
would ensure the user has made a valid selection.

Does this help?
--
HTH,
Rakesh Rajan
MVP, MCSD
http://www.msmvps.com/rakeshrajan/

"Will Lastname" wrote:
My application has a series of dropdownlists with AutoPostBack set to
True and IndexChanged handlers as well. All of the dropdownlists are
bound and dynamically populated.

Is there a way to manually add an entry to a dropdownlist that is
bound? The reason I ask is because if the first item is the one the
user wants to select it is not able to postback since it is already
selected.

Nov 19 '05 #2
> Is there a way to manually add an entry to a dropdownlist that is
bound?


Yes.

DropDownListNavigation.DataBind()
DropDownListNavigation.Items.Insert(0, New ListItem("Pick An Option",
"null"))

-Darrel
Nov 19 '05 #3
Thanks to both of you. I am sorry to say that I am still getting an
error stating that I can't modify this list when a datasource property
is set. Thanks anyway!

Nov 19 '05 #4
> Thanks to both of you. I am sorry to say that I am still getting an
error stating that I can't modify this list when a datasource property
is set. Thanks anyway!


Did you use the code example I showed you? That seems to work fine in my
application. What is the exact error you get?

-Darrel
Nov 19 '05 #5

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

Similar topics

2
by: Newbie | last post by:
I have a C# asp.net webform that contains a dropdownlist and a button that allows the user to select another item in the dropdownlist. The webform should work as follows: When the user selects...
2
by: Dominic | last post by:
Hi guys, I'm not sure if this question belongs to FAQ, but I couldn't find a concrete answer. I created a Datagrid control using ItemTemplate, but it's NOT a in-place editing datagrid. One of...
1
by: | last post by:
This is a crosspost from a less-frequented (but more focused) asp.net group; I didn't receive an answer that worked. I'd like to get this form functional. Could someone help on what's probably a...
3
by: Tim::.. | last post by:
Can someone please tell me how I go about preselecting an item in a drop drown list when I click the Edit Command in a datagrid? I have tried the following but it doesn't work for me! I would...
6
by: Julius Fenata | last post by:
Dear all, I have created client-side scripting to trigger event onChange from code-behind, like this: DropDownList1.Attributes = "GenerateArticleID()"; At the script on Windows Form, I...
1
by: Phil | last post by:
I would like to make the CreateUserWizard's security question box display as a databound (xml file) dropdownlist. I can make the dropdownlist display by using a contenettemplate, but I can't get...
0
by: Juanjo | last post by:
Hi, Before, I was working with Asp.net 1.0 and datagrid. I posted a question for this issue. The solution of this problem is load the second dropdownlist on the selectedindexchanged event of the...
4
by: glenn | last post by:
Hi folks, I am getting an error "Object reference not set to an instance of an object". It seems I have everything in place but something is obviously in err. If you could take a quick peak...
1
by: DJ | last post by:
I have a DropDownList in Visual Web Developer that is databound to a SQL Database. Whenever the web page is opened the DropDownList is automatically filled with the first item in the table. My...
6
by: shashi shekhar singh | last post by:
Respected Sir, I have to create multiple dynamic dropdownlist boxes and add items dynamically in <asp:table> server control but problem occurs , i.e. except of fist dropdown list no dropdownlist...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.