473,725 Members | 2,169 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 1523
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
2945
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
10839
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
7387
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
5853
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
2194
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
1683
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
8888
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
8752
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
9176
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
6011
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
4519
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
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3221
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
2635
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
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.