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

Dropdown lists

Hi-

I have created a dropdown list in my VB.net application, with data from
a database table - that works fine. I then added a record to a table
through a form that has this drop down list - that worked fine too. The
problem is now selecting and displaying this value. All the other
fields are displayed fine, but the drop down list comes out blank - any
idea as to what I am doing wrong?

Thanks
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #1
3 1246
- When you populate the ddlist the first time you are probably doing it in
the form_load event when not-is-post-back. You then display the form with the
DDList ok.
- When you use the DDList to select the item you want to select you are
either using an auto-post-back or you are selecting a
submit-button-of-some-kind. You are then posting to the server.
- In this case the aspx page is first loaded again (form_load() is run).
This is where you should be using the is-post-back part of code to get the
value of the DDList. At this point, if enable-viewstate is false on the
DDList, the page does not contain values to repopulate the DDList when it is
redispalyed.
-You can either enable-viewstate or repopulate the DDList yourself.
-If the post-back you are performing is the result of
add-this-new-record-to-the-DDList you will need to repopulate it anyway.
-You will also need to become familiar with the OnSelectedIndex_Change events.

(Please, don't take the names of the functions mentioned here literally. I'm
doing this off the top of my head.)


"Sara" wrote:
Hi-

I have created a dropdown list in my VB.net application, with data from
a database table - that works fine. I then added a record to a table
through a form that has this drop down list - that worked fine too. The
problem is now selecting and displaying this value. All the other
fields are displayed fine, but the drop down list comes out blank - any
idea as to what I am doing wrong?

Thanks
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 21 '05 #2
Hi Brad -

Thanks.

Here is what I am doing. Yes, I do all the steps you indicate. Then on a
if not ispostback I run a routine "Populate form" that runs a stored
procedure and selects a partcular record from the Database. Let's say
that the DDL was a list of students, then for this particular record I
have the student name in the record that was retrieved. I really don't
need to shoew the DDList again on the form as I don't want them changing
this value once entered anyway. But I cannot get the student name to
display at all. Typically a simple ddlname.selectedindex.text =
strstudentname
would have done it - but this time it will not work because the DDL was
created from a DB to begin with (my guess) - In the above scenario, how
can I populate that field on data retrieval? Thanks


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #3

I got it to work folks - thanks.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #4

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

Similar topics

4
by: Marc | last post by:
I've gotten everything up and running except for this -- I'd like to be able to have people have a dropdown list of cities in the US to use (or wherever) and not have to input them manually into a...
2
by: Ralph Freshour | last post by:
Is it possible to control the width of select dropdown lists? regardless of what text you type in? Thanks...
0
by: Mike O. | last post by:
MS Access 2003 "filter by form" has drop down lists that allow the user to select values for each field to filter by. However, once some values are selected,the remaining dropdown lists remain the...
0
by: Henke | last post by:
Hi, I have done some research about my problem I have when using the "back button" in IE to go back to a page with two dropdown lists. The both dropdown lists are populated with data. The...
2
by: Chris Becker | last post by:
This is my attempt to rephrase a question I asked earlier that got no response. I suspect it was my poor/unplanned wording. Here is another attempt: I have a form with some drop down lists. I...
1
by: Ed Chiu | last post by:
Hi, I have 2 dropdown lists on an ASP.Net page, the first is a list of states of US, the second is City list. When user selects a state, the web page does a postback, create a DB connection and...
1
by: cgian31 | last post by:
I have implemented a website where in a page are represented the data of one record, using cascade dropdown lists in 2 levels, within the same page/record. According to the selection in the...
2
by: Lair | last post by:
I am creating a page that has three to four databound dropdown lists. Each one is has different data sometimes from the same table but with a different where clause. What is the best way to...
1
by: eddie23 | last post by:
Hi group. we've an ASP.net application. there are dropdown lists all over it. we use IE6 SP2 here in work. When the dropdown is accessed by someone logged in as a local admin to the XP workstation...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.