| | |
Help with dropdownlist data adding?
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2005
Posts: 1
Reputation:
Solved Threads: 0
Well, I'm hoping someone can help me....
I've got a web application that queries data from a database based on selections made in previous dropdownlists. The problem is that some of the final queries return only one data item.
I'm using the onSelectedIndexChanged with autopostback enabled as my events in the lists. And thats the problem, if theres only one item in the dropdownlist, its imposible to change the index, thus I've got no event firing the next block of code I need executed...
If anyone has any idea on how to counter this problem, please help!
I thought if it were possible to add data to already manually inputted items already in the list, that'd be great, so that there's already 1 item in there before the other items are added... So that if only one item is retrieved by the from the database, there will be at least two items in there, allowing a change in the selected index...
Just how to do that though, I have no idea!
I've got a web application that queries data from a database based on selections made in previous dropdownlists. The problem is that some of the final queries return only one data item.
I'm using the onSelectedIndexChanged with autopostback enabled as my events in the lists. And thats the problem, if theres only one item in the dropdownlist, its imposible to change the index, thus I've got no event firing the next block of code I need executed...
If anyone has any idea on how to counter this problem, please help!
I thought if it were possible to add data to already manually inputted items already in the list, that'd be great, so that there's already 1 item in there before the other items are added... So that if only one item is retrieved by the from the database, there will be at least two items in there, allowing a change in the selected index...
Just how to do that though, I have no idea!
Yep, having a default value for drop down lists is a good habit to get into I think. Try code something like this:
VB.NET Syntax (Toggle Plain Text)
Dim rdrCategory As SqlDataReader myConnection.Open() rdrCategory = cmdSelect.ExecuteReader(CommandBehavior.CloseConnection) Dim liDefault As ListItem liCategory = New ListItem([insert text for default entry here as String], [insert default value here as String]) lstCategories.Items.Add(liDefault) Do While rdrCategory.Read() liCategory = New ListItem(rdrCategory("ShortName"), _ rdrCategory("CategoryID") lstCategories.Items.Add(liCategory) Loop rdrCategory.Close()
•
•
Join Date: Jun 2005
Posts: 9
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by Lemon
Well, I'm hoping someone can help me....
I've got a web application that queries data from a database based on selections made in previous dropdownlists. The problem is that some of the final queries return only one data item.
I'm using the onSelectedIndexChanged with autopostback enabled as my events in the lists. And thats the problem, if theres only one item in the dropdownlist, its imposible to change the index, thus I've got no event firing the next block of code I need executed...
If anyone has any idea on how to counter this problem, please help!
I thought if it were possible to add data to already manually inputted items already in the list, that'd be great, so that there's already 1 item in there before the other items are added... So that if only one item is retrieved by the from the database, there will be at least two items in there, allowing a change in the selected index...
Just how to do that though, I have no idea!
hi
u can make a check for only one item in the dropdownlist ,if its true make a call to the onSelectedIndexChanged with the required parameter
hope this helps u out
![]() |
Similar Threads
- Inserting multiple data with cfloop? (ColdFusion)
- Help with Linked Lists with digits (C++)
- listbox hiccup (Visual Basic 4 / 5 / 6)
- DropDownList items (ASP.NET)
- how to adding data in dataset (ASP.NET)
- New server to replace old W2K DC server (Windows NT / 2000 / XP)
Other Threads in the VB.NET Forum
- Previous Thread: Please Help!!!!
- Next Thread: MS Visual Basic.NET Step by Step
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2005 2008 access account arithmetic array assignment basic binary bing box button buttons center check code component connectionstring convert cpu crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net dropdownlist editvb.net excel file-dialog firewall folder ftp hardcopy image images insert isnumericfuntioncall login math memory mobile ms mssqlbackend mysql navigate net networking opacity output passingparameters peertopeervideostreaming picturebox1 port printpreview problemwithinstallation project record reports" reuse save savedialog serial soap storedprocedure string tcp temp text textbox timer toolbox trim update updown useraccounts usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio web wpf





