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

Select Maximum Value from Dropdownlist

parshupooja
159 100+
Hey All,

I know its silly question but help me here.
I have dropdown which is getting populated dynamic from Database with number like 1,2 ,3, 4, 6,12 etc.

By Default I want maximum number to be selected once dropdown is populated.

Thanks!
Jun 10 '08 #1
7 9074
Plater
7,872 Expert 4TB
If they populate in order, just select the highest index?
Jun 10 '08 #2
Curtis Rutland
3,256 Expert 2GB
If they don't populate in order, think about using an ORDER BY statement to make that happen. If that isn't possible, after it is bound, loop through the values, converting each to an Int32 (or whatever you need) and remember the index of the highest value. Then just set the selected index to the index that you saved.
Jun 10 '08 #3
parshupooja
159 100+
If they populate in order, just select the highest index?
wat is syntax of selecting higest index?
Jun 10 '08 #4
Plater
7,872 Expert 4TB
Expand|Select|Wrap|Line Numbers
  1. myComboBox.SelectedIndex = (myComboBox.Items.Count - 1)
  2.  
Jun 10 '08 #5
parshupooja
159 100+
Expand|Select|Wrap|Line Numbers
  1. myComboBox.SelectedIndex = (myComboBox.Items.Count - 1)
  2.  
Thankx. Now how should I get value of Highest Index? Since dropdown list is dynamic. number of item may change anytime. suppose i want to Find out value of item where index is 5.

Thanks!
Jun 10 '08 #6
Plater
7,872 Expert 4TB
Thankx. Now how should I get value of Highest Index? Since dropdown list is dynamic. number of item may change anytime. suppose i want to Find out value of item where index is 5.

Thanks!
What?
Whenever you populate your dropdown and want the highest indexed item to be selected, run that line of code.

myComboBox.Items[X] will return (as an object) whatever data is stored at index X
Jun 10 '08 #7
parshupooja
159 100+
thankQ i am half sleep.

ddpaycycle.Items(X).Value

What?
Whenever you populate your dropdown and want the highest indexed item to be selected, run that line of code.

myComboBox.Items[X] will return (as an object) whatever data is stored at index X
Jun 10 '08 #8

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

Similar topics

0
by: Jan | last post by:
I store sql-commands in a database table. In the first step I get the sql command out of the database table with embedded sql. In the second step I try to execute the command, which i got from the...
3
by: Northern | last post by:
I have an ASP DropdownList populated. What I want is to select a new item, in my code, by set a datavale to dropdownlist's selectedItem.Value property. I did the following: ...
0
by: Stephan Bour | last post by:
I need to implement a simple search function to lookup order information in a SQLserver table. The code below works fine for a search to the ³OrderID² column. However, I¹d like to offer the user...
7
by: localhost | last post by:
A DataGrid with shows a label in one of the columns when in view mode. When in edit mode, I want to show a dropdown, and have the default selection set to what the textbox used to be. Right now...
6
by: Chris Fink | last post by:
Does anyone know it is possible to include a small image(.gif .jpeg) within a <SELECT><option> so that the user would see the option text as well as a little image(icon) in the option? I know this...
4
by: =?Utf-8?B?c2lMdmVy?= | last post by:
Hhi, I'm working on an asp .net project that have small side panel which 'disallow' long SELECT/dropdown list.. So i could not force them to a certain that shows my longest option, which now...
13
by: PinkBishop | last post by:
I am using VS 2005 with a formview control trying to insert a record to my access db. The data is submitted to the main table no problem, but I need to carry the catID to the bridge table...
3
by: Lohboy | last post by:
Using ASP.NET and IE7. (Sorry if I am posting in the wrong forum but my problem seemed to be more related to the JavaScript side than the ASP.NET side.) I have two DropDownList controls the...
0
by: Moneypenny | last post by:
Hi there, I have a Gridview control which has a dropdownlist in every row. The dropdowns are populated dynamically from a database (so the content is different in each row. There is also a select...
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...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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: 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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.