G
Guest
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:dropdownlist id="ddlStartTimeHour" runat="server" />
<asp:dropdownlist id="ddlEndTimeHour" runat="server" />
<asp:dropdownlist id="ddlStartTimeMinute" runat="server" />
<asp:dropdownlist id="ddlEndTimeMinute" runat="server" />
these are declared in the C# as
protected System.Web.UI.WebControls.DropDownList ddlStartTimeHour;
protected System.Web.UI.WebControls.DropDownList ddlStartTimeMinute;
protected System.Web.UI.WebControls.DropDownList ddlEndTimeHour;
protected System.Web.UI.WebControls.DropDownList ddlEndTimeMinute;
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["SessionTimeStart"].ToString().Split(':');
timeEnd = dr["SessionTimeEnd"].ToString().Split(':');
ddlStartTimeHour.Items.FindByValue(timeStart[0]).Selected = true;
ddlStartTimeMinute.Items.FindByValue(timeStart[1]).Selected = true;
ddlEndTimeHour.Items.FindByValue(timeEnd[0]).Selected = true;
ddlEndTimeMinute.Items.FindByValue(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 ddlStartTimeHour 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
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:dropdownlist id="ddlStartTimeHour" runat="server" />
<asp:dropdownlist id="ddlEndTimeHour" runat="server" />
<asp:dropdownlist id="ddlStartTimeMinute" runat="server" />
<asp:dropdownlist id="ddlEndTimeMinute" runat="server" />
these are declared in the C# as
protected System.Web.UI.WebControls.DropDownList ddlStartTimeHour;
protected System.Web.UI.WebControls.DropDownList ddlStartTimeMinute;
protected System.Web.UI.WebControls.DropDownList ddlEndTimeHour;
protected System.Web.UI.WebControls.DropDownList ddlEndTimeMinute;
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["SessionTimeStart"].ToString().Split(':');
timeEnd = dr["SessionTimeEnd"].ToString().Split(':');
ddlStartTimeHour.Items.FindByValue(timeStart[0]).Selected = true;
ddlStartTimeMinute.Items.FindByValue(timeStart[1]).Selected = true;
ddlEndTimeHour.Items.FindByValue(timeEnd[0]).Selected = true;
ddlEndTimeMinute.Items.FindByValue(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 ddlStartTimeHour 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