473,796 Members | 2,482 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 2195
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******** *************@t 31g2000cwb.goog legroups.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.goo glegroups.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.goo glegroups.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
5483
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 dropdownlist to the screen for selection. This continues until there are no children, and then it checks for a help article list based on that last selection and displays actual articles for display. Adding the controls and getting everything...
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. Private Sub DataList1_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles DataList1.ItemCreated Dim ddl As DropDownList ddl = CType(e.Item.FindControl("DropDownList1"), DropDownList)
0
1590
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. An 'All' list item is added to the child dropdown during the CreateControlHeirarchy(bool useDataSource) method. Somewhere between the CreateControlHeirarchy method executing and the
1
2033
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 question is, how do I set it so that the DropDownList is empty until a value is selected?
0
2387
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 ItemTemplate in the GridView populated with three ListItems. A Button to Submit the form.
3
9849
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 control inside a parent user control with an update panel. Can you guys help me hwo to retain the values. I have set EnableViewState to true. Where is correct page event to store entered and selected values before the values on controls are...
2
6364
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 DropDownLists. I don't lose the SelectedIndex when the ViewState is enabled, only when it is off. I have a dropdownlist named countryCbo inside of a UserControl and countryCbo's EnableViewState property is false. In the OnInit() method of the UserCountry...
1
4662
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 ,another row will be created with the same control (I mean another dropdown and 2 button) and so on. and by pressing Remove button the selecetd row will be removed. I used viewstate to keep my value for postback, I want by changing selectedvalue of...
0
3502
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- 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 ,another row will be created with the same control (I mean another dropdown and 2 button) and so on. and by...
0
10455
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10228
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10173
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
10006
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
9052
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4116
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
3
2925
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.