c# - ASP.NET: Remove specific item in Dropdownlist -


I'm doing a code for time and timeouts, so I've done manual coding.

Here is my example:

Its HH: MM

Value time is 00 - 23 then for 00 is from 00 - 59

Scenario:

< P> My start time will be 8:00 [8-hour, 00-minute], it will also have an autopost, so for the time of the end it will not display 00-07, it will only show numbers 8 to 23.

Here is my code:

  int _intDiff = _tmrStart - _tmrEnd; For (int x = 0; x & lt; = _intDiff; x ++) {dropdown list 3.image. Remove (dropdown list 3.tim [x]); }  

It works but its wrong output is displayed ..

Here is an example:

As you can see there, the program is only 0,02,04,06 , Also removes the number 08 How can I do that the 00 -07 will be removed in the drop-down list?

If after this you remove the first element first, which is 00. In the second stage, the second element is removed, which is not 02, because 01 has reached the first element. You need to iterate backwards so that the elements can be removed before the last one. Try:

 for  (int x = _intDiff -1; x & gt; -1; x--) {DropDownList3.Items.Remove (DropDownList3.Items [x]); }  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -