Hi peeps
OK, I'm getting a weird error trying to select a DDL item based on what's
stored in the database.
I have 4 DDLs on my aspx page...
<asp:dropdownli st id="ddlStartTim eHour" runat="server" />
<asp:dropdownli st id="ddlEndTimeH our" runat="server" />
<asp:dropdownli st id="ddlStartTim eMinute" runat="server" />
<asp:dropdownli st id="ddlEndTimeM inute" runat="server" />
these are declared in the C# as
protected System.Web.UI.W ebControls.Drop DownList ddlStartTimeHou r;
protected System.Web.UI.W ebControls.Drop DownList ddlStartTimeMin ute;
protected System.Web.UI.W ebControls.Drop DownList ddlEndTimeHour;
protected System.Web.UI.W ebControls.Drop DownList ddlEndTimeMinut e;
They are populated on Page_load with a couple of for loops (09, 10, 11 etc
for hour, 00,15,30,45 for minute). Then, Im trying to select the correct data
based on a DataReader as follows..
string[] timeStart, timeEnd;
timeStart = dr["SessionTimeSta rt"].ToString().Spl it(':');
timeEnd = dr["SessionTimeEnd "].ToString().Spl it(':');
ddlStartTimeHou r.Items.FindByV alue(timeStart[0]).Selected = true;
ddlStartTimeMin ute.Items.FindB yValue(timeStar t[1]).Selected = true;
ddlEndTimeHour. Items.FindByVal ue(timeEnd[0]).Selected = true;
ddlEndTimeMinut e.Items.FindByV alue(timeEnd[1]).Selected = true;
The first two (the Start times) seem to work fine, but I get an error on the
EndTimeHour that says "A DropDownList cannot have multiple items selected". I
dont understand why this is happening, it happens even if I add
ddlEndTimeHour. SelectedItem = -1.
Even odder than that... the StartTime for the test date is 14:00, and the
end time is 15:30. Obviously theStartTIme works, but if I comment out the 2
EndTime.Select lines, the EndTime DDLs shows 14:00 as well!
It's as if ddlStartTimeHou r and ddlEndTimeHour are connected, hence I get
the error about no multiples. But that *cant* be the case... can it?!
Any help appreciated!
Cheers
Dan