473,508 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DropDownList doesn't carry correct Viewstate selectedIndex

Apparently if you have any duplicates in your Value collection the
selected index that is maintained through the state defaults to the
first index in that group of duplicates.

So my items correspond to the Box_Id in the table (the unique
identifier in the DB). There are 8 boxes, 1-8. Then I grab a business
related date and fill the Value collection with this, that date
corresponds to something with each box. The dates (which become
values) could all be different or the same, there is no consistency
with the dates. Well boxes 1-6 all had the same recieve date so the
value was the same for all those items. Therefore, if you select
anything within "Index" 0-5 it will default to 0 because that is the
first item in the list with the duplicated date. Same for "Index" 6-7.
So when it is maintaining its state it remembers the selected index,
but won't allow duplicates in the value field. They should provide a
property which allows duplicates in the value field.

Is this a bug or intentional?

Apr 10 '06 #1
7 2183
This is all through a postback by the way

Apr 10 '06 #2
Is this a bug or intentional?


Just a WILD guess, but I assume viewstate for DDL's default to the value
field.

You may have to write your own check that grabs the selected index on
postback and reset it yourself.

-Darrel
Apr 10 '06 #3
Sounds like you have a bad design to me. Why would you want duplicates in a
list anyway? Which one would the user want to select?? Very confusing. I
would say the behavior you are seeing is by design

Jeff

"Phuff" <pc*****@gmail.com> wrote in message
news:11*********************@t31g2000cwb.googlegro ups.com...
Apparently if you have any duplicates in your Value collection the
selected index that is maintained through the state defaults to the
first index in that group of duplicates.

So my items correspond to the Box_Id in the table (the unique
identifier in the DB). There are 8 boxes, 1-8. Then I grab a business
related date and fill the Value collection with this, that date
corresponds to something with each box. The dates (which become
values) could all be different or the same, there is no consistency
with the dates. Well boxes 1-6 all had the same recieve date so the
value was the same for all those items. Therefore, if you select
anything within "Index" 0-5 it will default to 0 because that is the
first item in the list with the duplicated date. Same for "Index" 6-7.
So when it is maintaining its state it remembers the selected index,
but won't allow duplicates in the value field. They should provide a
property which allows duplicates in the value field.

Is this a bug or intentional?

Apr 10 '06 #4
Well, its simple. at the top you have a job order, which can have one
or more box units in it. Each box is a designed unit in an engineering
aplication (this "box" is something that gets built). They selected
the job already, and this is the page for when engineering received the
box. Lets say there are 5 boxes. It "could" be that engineering
received them over 5 days so each Recieve_Date could be different.
Also, they could have recieved each box in the same day, in which case
the Receive_Date would be the same for all.

On my drop down list the items (text which the user can see) is the
Box_ID. That is the unique identifier in the table and happens to be
the box's name as well. Thats what I want the user to see. With each
box is an associated date, which I grab from the database, and so I
don't have to reach into the database on every load I associated the
value for each item with its corresponding date. Yes, I can just
dynamically grab from the database, but is Progress and its old and
slow. Yes I can store the dates in an array and keep as a session
variable, I just found it wierd that I couldn't use the value
collection in this manner. It should maintain selected index despite
the values in the Item or Value collections.

Apr 10 '06 #5
Yep, bad design. Using duplicate dates as a dropdown Value?? Um, why not use
the box_id as both the Text and Value?

Jeff

"Phuff" <pc*****@gmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
Well, its simple. at the top you have a job order, which can have one
or more box units in it. Each box is a designed unit in an engineering
aplication (this "box" is something that gets built). They selected
the job already, and this is the page for when engineering received the
box. Lets say there are 5 boxes. It "could" be that engineering
received them over 5 days so each Recieve_Date could be different.
Also, they could have recieved each box in the same day, in which case
the Receive_Date would be the same for all.

On my drop down list the items (text which the user can see) is the
Box_ID. That is the unique identifier in the table and happens to be
the box's name as well. Thats what I want the user to see. With each
box is an associated date, which I grab from the database, and so I
don't have to reach into the database on every load I associated the
value for each item with its corresponding date. Yes, I can just
dynamically grab from the database, but is Progress and its old and
slow. Yes I can store the dates in an array and keep as a session
variable, I just found it wierd that I couldn't use the value
collection in this manner. It should maintain selected index despite
the values in the Item or Value collections.

Apr 10 '06 #6
Because I still need that date. Sure I could use the ID as both but
then I would need to make a call to the database when I need the date.
What I did was grab my dates and for loop through and place in session
variables that way I only needed to connect to the database on first
page load.

As far as the bad dplicate dates, I didn't realize it would be a
problem in the control. It took me a bit to realize the dates were the
issue. Some of these jobs will have a different date for each unit or
no date at all.

Apr 11 '06 #7
You can put Objects in there too, not just scalar values. Put a struct that
has both box_id and date.

Jeff

"Phuff" <pc*****@gmail.com> wrote in message
news:11**********************@z34g2000cwc.googlegr oups.com...
Because I still need that date. Sure I could use the ID as both but
then I would need to make a call to the database when I need the date.
What I did was grab my dates and for loop through and place in session
variables that way I only needed to connect to the database on first
page load.

As far as the bad dplicate dates, I didn't realize it would be a
problem in the control. It took me a bit to realize the dates were the
issue. Some of these jobs will have a different date for each unit or
no date at all.

Apr 11 '06 #8

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

Similar topics

4
5449
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
2
797
by: Ashish Sharma | last post by:
I have a DropDownList inside a DataList on a page. I want to set the selectedindex property of the DropDownList to some value. I bind the DropDownList on the ItemCreated Event of the DataList. ...
0
1580
by: fwirtanen | last post by:
I am building a custom composite control consisting of two drop downs, with parent/child dependancy. The child dropdownlist is updated through client callback when the parent index changes. ...
1
2019
by: DJ | last post by:
I have a DropDownList in Visual Web Developer that is databound to a SQL Database. Whenever the web page is opened the DropDownList is automatically filled with the first item in the table. My...
0
2361
by: reddog | last post by:
Getting the SelectedIndex of a DropDownlist under the ItemTemplate in a GridView is harder than I thought it would be. I have: A Gridview of n rows bound to a DataSet. A DropDownList as an...
3
9829
by: =?Utf-8?B?ZGVuIDIwMDU=?= | last post by:
Hi, Trouble in retaining values of dropdownlist, textboxes, and other controls when dropdownlist selectedindexchanged event is triggered, the controls are inside a user control and this user...
2
6351
by: jwnews1231 | last post by:
Hi, I've been working on minimizing the use of the ViewState in my asp.net applications because of its overhead. The problem I am having is that I keep losing SelectedIndex in the...
1
4638
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
3467
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
0
7398
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7061
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...
0
7502
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...
0
5637
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4716
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...
0
3194
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1566
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 ...
1
769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
428
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...

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.