473,395 Members | 2,468 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,395 software developers and data experts.

set default value in dynamic drop down

There is dropdown on webpage and I m filling it dynamically at run time. I want to set an item as selecteditem. that item will be decided on the page load based upon value I got from databse.
I set DataTextField,DataValueField properties of dropdown.
Initially I got data printed on label and set dropdown.selectedvalue=label1.text
it was working fine before setting DataValueField.
after setting DataValueField,it is throwing error "item you are trying to set as selecteditem is not in the list."
Please tell me some solution.
Mar 28 '08 #1
5 1341
malav123
217 100+
Hi garima,
I am not getting exactly what is problem in your application.... so please tell me the problem clearly...
Mar 28 '08 #2
Plater
7,872 Expert 4TB
Set the SelectedIndex to a value?
Mar 28 '08 #3
balabaster
797 Expert 512MB
Set the SelectedIndex to a value?
Plater, I don't think she's asking quite what you think. In the database, she's storing the selected value which you can't set at runtime, only read. So we have to find the index from the value.

Dim MyValue As Integer = OledbDataReader1("StoredValue")
MyDropList.SelectedIndex = MyDropList.IndexOf(MyDropList.FindByValue(MyValue) )
Mar 28 '08 #4
Plater
7,872 Expert 4TB
You just described in much better depth what I was trying to get out.
Sometimes work eats my brain.
Mar 28 '08 #5
balabaster
797 Expert 512MB
You just described in much better depth what I was trying to get out.
Sometimes work eats my brain.
It's odd...I'm at work, stuck in meetings...and I spend more time answering questions on here so that the incessant roundabout conversations don't eat my brain.
Mar 28 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Xerxes | last post by:
Hi, how can I pass the returned value from Javascript to PHP? I have: ------------------------------------------------------------------------ ------ if ( x>y) {
7
by: deko | last post by:
I populate a drop-down list like this: echo "<select>"; foreach ( $ip_list as $var ) { echo "<option>"; echo $var; echo "</option>"; } echo "</select>";
3
by: julian | last post by:
hi I was wondering if anyone can help me out on this.... I have dynamcally populated a drop down menu with data from an access database using ASP. The values seem fine, however when i pass...
2
by: akl | last post by:
How can I create such a default value that it depends on the value in other field (drop down)? So that the default value would be updated every time I change the value of drop-down field.
1
by: Null | last post by:
Hello -- Is there a way to prevent the autopostback of a drop down list if there is a "default" item in the list -- example, a drop down list where the first item says "Select One" and the...
0
by: clickon | last post by:
I want to use the selected value of a drop down list to filter a data source. When i have done this before i have used a DataSourceControl and i have just made the drop down a control parameter,...
1
by: clickon | last post by:
I want to use the selected value of a drop down list to filter a data source. When i have done this before i have used a DataSourceControl and i have just made the drop down a control parameter,...
1
by: azeemqaiser | last post by:
Hi All, I have a form with two drop down controls. I want to change the values of Drop Down Menu 2 if i select some value in Drop Down Menu 1. Like If i select country then all the states of...
3
by: amcoldspy | last post by:
Hi, am trying to create dynamic drop down boxes.. there are 3 drop down boxes. The second drop down box elements are to be update based on the selection made in the first drop down box...
4
by: phpmagesh | last post by:
Hi I am using php and smarty, what i have to do is i have a drop down box with dynamic name, id and values. like <select name="id" id="id" onchange="sample()" > {foreach key=key_data...
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: 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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.