|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Dropdownlist
Hi
I have a dropdownlist which consists of numeric values that represent 5-minute intervals which are displayed in ascending order i.e. 00 05 10 15 20 25 30 35 40 45 50 55 When the page is loaded, a default value is selected based on the current time. However, when this default value is selected, it alters the order of all the other values on the dropdownlist, and the default value itself becomes the first value in the dropdownlist. e.g. 25 30 35 40 45 50 55 00 05 10 15 20 How do I keep the exact order of these values? Here is the code private void getMinute() { DateTime dateTime = DateTime.Now; string strHourMin,lstItem,strMin =null; string[] values; char[]delimiters = {':',' '}; strHourMin = dateTime.ToString("t"); values = strHourMin.Split(delimiters); int minute = System.Convert.ToInt32(values[*1]); int tempMinute = 0; string strTempMin = null; string strRightDigit = values[1].Substring(1,1); string strLeftDigit = values[1].Substring(0,1); int intRightDigit = System.Convert.ToInt32(strRigh*tDigit); int intLeftDigit = System.Convert.ToInt32(strLeft*Digit); if (intRightDigit <5) { strTempMin = intLeftDigit.ToString() + "5"; } else { tempMinute = intLeftDigit + 1; strTempMin = tempMinute.ToString() + "0"; } int intMinute = System.Convert.ToInt32(strTemp*Min); strMin = intMinute.ToString("00"); for (int i =0;i<11;i++) { intMinute = (intMinute + 5); if (intMinute > 55) {intMinute =0;} lstItem = intMinute.ToString("00"); sltMinute.Items.Insert(i,new ListItem(lstItem)); } } Many Thanks Niju |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > Dropdownlist |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|