473,944 Members | 11,901 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

weird DropDownList problem..

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
Nov 19 '05 #1
0 1166

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1670
by: shamila | last post by:
</asp:label><asp:datagrid id="DataGrid3" runat="server" cssclass="DataGrid" showfooter="True" onupdatecommand="DataGrid3_Update"ondeletecommand="DataGrid3_Delete" oneditcommand="DataGrid3_Edit" oncancelcommand="DataGrid3_Cancel" caption="Pricing Schedules" autogeneratecolumns="False" OnItemDataBound="ItemDataBoundEventHandler"> <alternatingitemstyle cssclass="DataGrid_AlternatingItemStyle" /> <columns> <asp:templatecolumn...
3
1317
by: Wayne Dyer | last post by:
I can duplicate this, so I know it's not something I'm imagining and wonder if anyone else has seen it. Take a page, put a drop down control on it, hook up the onChange event handler to go get some data in the postback based on the selected index that takes 3-4 seconds to return. While the postback is occurring, click on the drop down box and *leave it open* while the postback returns.
1
1737
by: BW | last post by:
Hello, I am attempting to to take edited values from a datagrid control and update the underlying database. Problem is that some of the edited values don quite seem to make it to my update sub. My code is shown below. The values that are not appearing are Cell(4) - sCompletion and Cell(5) - sNote. The other values show up just fine. What am I missing here?
4
2023
by: Mark Waser | last post by:
I've discovered a very odd bug when attempting to put a dropdown list in a datagrid. In the page PreRender step, the selected index of the datagrid is successfully set during databinding. Yet, when the datagrid enters it's own OnPreRender, the selected index has reverted to zero. I created a debug version of the dropdown list which inherited from dropdownlist and overrode the selected index property to trace.write whenever it was...
0
10148
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9974
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
11317
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10679
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7402
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6315
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4927
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4519
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3523
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.