Skip to content

Disable time end time based on start time from drop down lis

Priya Bm

Asked Jun 26, 2015, 4:39 AM EDT1 answer
Share
LinkedInX
Hi,
 
I want to disable end time based on start time selection. i am using listitem in grid
 
eg: Suppose I select 12:00 from start time dropdown list.   
      Now  in end time before 12:00 all the time should be disable.
 
how to achieve this through c# ?
Pls help..... 

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • +1
    Hi Priya,
     
    try this it might help.
     
    protected void StartTime_SelectedIndexChanged(object sender, EventArgs e)
    C#
            {
                foreach ( ListItem item in EndTime.Items )
                {
    if (DateTime.ParseExact(item.Value.ToString(), "HH:mm", CultureInfo.InvariantCulture).TimeOfDay < DateTime.ParseExact(StartTime.SelectedValue.ToString(), "HH:mm", CultureInfo.InvariantCulture).TimeOfDay)
                    {
                        item.Enabled = false;
                    }
                    else
                    {
                        item.Enabled = true;
                    }
                }
            }
     
    +1