473,714 Members | 2,623 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dropdown problem with setting selected values

Hi,

I'm trying to write a web page containing three dropdowns. The
dropdowns are declared as follows:

<asp:DropDownLi st id="cmbCat1" runat="server"
AutoPostBack="t rue"></asp:DropDownLis t>
<asp:DropDownLi st id="cmbCat2" runat="server"
AutoPostBack="T rue"></asp:DropDownLis t>
<asp:DropDownLi st id="cmbCat3" runat="server"
AutoPostBack="T rue"></asp:DropDownLis t>

When trying to set a selected value to each of them, the others are
influenced for some reason. Their selected value is set as well. This
is the code:

cmbCat1.Selecte dValue = Session["cat1"].ToString();
cmbCat2.Selecte dValue = Session["cat2"].ToString();
cmbCat3.Selecte dValue = Session["cat3"].ToString();

Any ideas why this is happening and what I need to do to make them
independant?

Thanks!

Dec 3 '05 #1
7 1520
Without more information my suggestion would be to take a look at where you
set those session variables. Make sure they aren't all being set to the
same value.

--

Derek Davis
dd******@gmail. com

<se*********@gm ail.com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
Hi,

I'm trying to write a web page containing three dropdowns. The
dropdowns are declared as follows:

<asp:DropDownLi st id="cmbCat1" runat="server"
AutoPostBack="t rue"></asp:DropDownLis t>
<asp:DropDownLi st id="cmbCat2" runat="server"
AutoPostBack="T rue"></asp:DropDownLis t>
<asp:DropDownLi st id="cmbCat3" runat="server"
AutoPostBack="T rue"></asp:DropDownLis t>

When trying to set a selected value to each of them, the others are
influenced for some reason. Their selected value is set as well. This
is the code:

cmbCat1.Selecte dValue = Session["cat1"].ToString();
cmbCat2.Selecte dValue = Session["cat2"].ToString();
cmbCat3.Selecte dValue = Session["cat3"].ToString();

Any ideas why this is happening and what I need to do to make them
independant?

Thanks!

Dec 5 '05 #2
I would also like to know where your combo's are getting populated
from. Are you data-binding them to a datatable in code behind?
If so, is it the same data table for all 3? If so, thats probably your
problem. Otherwise as carion suggested... your 3 session variables
might be the 1 object.

Steven Nagy

Dec 5 '05 #3

Steven Nagy wrote:
I would also like to know where your combo's are getting populated
from. Are you data-binding them to a datatable in code behind?
If so, is it the same data table for all 3? If so, thats probably your
problem. Otherwise as carion suggested... your 3 session variables
might be the 1 object.

Steven Nagy


Hi,
I'm not databinding them, but I'm inserting Items in a loop. The items
I'm inserting are the same because these three combos should contain
the same data. So what I'm doing is creating a listitem and adding it
to all three combos. Do you think this might be the problem?

Thanx

Dec 5 '05 #4
Hi,
Actually my first guess was that something was wrong w. the session
variables, so I tries setting the selected values to hard coded values,
but I got the same result...

Thanx

Dec 5 '05 #5
Almost definately.

The list item is a reference type, which means you are adding the same
object to all 3 lists.
Try creating an individual object for each one.

Steven Nagy

Dec 5 '05 #6
That was it.

Thanks a lot!!!

Dec 6 '05 #7
No problems.

The same issue applies in Windows Applications as well.

Any other cases where you want to use 1 data table for 3 different
combos, you can either have 3 data tables OR 1 data table and 3 data
views.
This is not relevant for you of course, but I thought I would post it
anyway in case someone else was looking for a solution to something
similar and their searches took them here.

Steven Nagy

Dec 7 '05 #8

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

Similar topics

1
2944
by: middletree | last post by:
For an ASp Intranet app, I have some code that should work, but I am not able to make it happen for some reason, after spending considerable time on this. I am pretty thick when it comes to javascript; I just don't get the syntax at all. If anyone could help, I would appreciate it. I'm probably pretty close. Please note that because it's an Intranet, all users have to use IE 5 or higher. Situation: 3 form fields on an ASP. <select>...
5
10838
by: Kris Rockwell | last post by:
Hello (again), I have gotten the dropdown list functionality to work through a few tricks (probably not the most efficient, but it works) but I am not sure how to set the default selected value. I have tried setting various values to represent the default value with little success. Essentially I am looking to have the first item in the list be the default selected item. I noticed in the properties for a dtat grid you could set a default...
2
7385
by: tmeister | last post by:
I must be missing something obvious. I have a drop down list in asp.net and it populates the states from a database. When I view the source of the page I get the standard option tags with the associated values. It all looks good. When I submit the form and some of the required fields aren't filled in the dropdown always reset to the first item in the list. First, how do I get it to stick. I've tried setting enableviewstate to true, but...
2
4551
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was set to...it is set to false. Can someone show me what I am doing wrong and tell me the correct way? Thank you. In the page load event, I am doing the following:
0
2909
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string strDataValueField; string strDataTextField; public CreateEditItemTemplateDDL(string DDLName,string DataValueField,string
6
5852
by: yasodhai | last post by:
Hi, I used a dropdown control which is binded to a datagrid control. I passed the values to the dropdownlist from the database using a function as follows in the aspx itself. <asp:DropDownList ID="FldType_add" Runat="server" DataSource='< %#GetFieldType()%>' DataValueField="Type" DataTextField="Type" /> Oce the page is loaded all the values are added to the dropdown list. But when I thought of getting the selected value from the...
13
2191
by: Shutey | last post by:
I have a strange issue with dropdowns. Using php4, mySQL5, Apache 2 on a fast XP pro PC, I have a form which requires 5 dropdowns populated with indentical values. I extract the values using SQL and populate 2 variables and use a for-next loop to create the dropdown. The dropdown contains some 310 items! It works beautifully if I have 1 or 2 dropdowns but as soon as I add more it partially creates the 3rd and just stops until it times out!...
4
4586
by: zion4ever | last post by:
Hello good people, Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet reservation of available resources (laptops, beamers, etc). The MySql database queries are already in place, as is the ASP administration panel. The frontend that users will see however, still needs some work. I'm really close, but since I'm no...
2
1681
by: raaman rai | last post by:
i have 3 drop dropdown box which is used for searching my database. Either one of them can be selected to perform the search but if none of them is selected it will give an error. Well in reference to this i want the sql query to be based on the values selected by the users. A user might select value from one dropdown box and leave the others or a user can also select values from all three dropdown box. So in this case the query parameters for...
3
2785
by: John | last post by:
I have two dropdown lists that I have bound to a datatable and set the DataTextField and DataValueField for. Both lists show the values I expect from the database. However, when I need to access the valueField for a dropdown list I always get the first value. Here is my code I do on load to bind the dropdowns: Try 'load the Division Dropdown dtDiv = objDAL.ExecuteDataTable("GetDivision") With ddDivision
0
8801
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
9314
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
9174
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...
0
7953
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...
1
6634
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5947
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
4464
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
4725
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3158
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

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.