473,776 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASCX User Control Drop Down List Issues

I have an ASCX user control with a drop down list inside an ASPX (C#)
page. The user selects an item from the DDL, clicks a button, and the
DDL.SelectedVal ue is supposed to be sent to another function. However,
the SelectedValue is always the first value in the DDL. I have tried
several methods to work around this including the examples at:

http://www.mastercsharp.com/article....=67&&TopicID=2
http://odetocode.com/Articles/116.aspx

Everytime however no matter what method is used, I cannot get the true
SelectedValue of the drop down list.

All the functions required are inside the ASCX page, there is nothing
needing to be called in the parent ASPX or C# code-behind.

Any ideas?! Thanks in advance!

Nov 19 '05 #1
3 2211
Have you checked If the databinding happening in all postbacks?
The code in Page_load of control should be like below

if(!Page.IsPost Back())
{
yourDDl.datasou rce =something;
yourDDl.DataBin d();
}

"ru*******@gmai l.com" wrote:
I have an ASCX user control with a drop down list inside an ASPX (C#)
page. The user selects an item from the DDL, clicks a button, and the
DDL.SelectedVal ue is supposed to be sent to another function. However,
the SelectedValue is always the first value in the DDL. I have tried
several methods to work around this including the examples at:

http://www.mastercsharp.com/article....=67&&TopicID=2
http://odetocode.com/Articles/116.aspx

Everytime however no matter what method is used, I cannot get the true
SelectedValue of the drop down list.

All the functions required are inside the ASCX page, there is nothing
needing to be called in the parent ASPX or C# code-behind.

Any ideas?! Thanks in advance!

Nov 19 '05 #2
Thanks, I knew it was something simple. Too bad I wasted many hours on
a complex solution not needed!

Nov 19 '05 #3
Do you have an event handler for the drop down list's SelectionChange d
event? That would be an ideal spot to pick up the new value - I'm not
sure how data binding will help.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On 19 Oct 2005 11:01:18 -0700, "ru*******@gmai l.com"
<ru*******@gmai l.com> wrote:
Thanks, I knew it was something simple. Too bad I wasted many hours on
a complex solution not needed!


Nov 19 '05 #4

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

Similar topics

1
2617
by: George Durzi | last post by:
I have a JavaScript called common.js that is referenced by every ASPX in my web application. In common.js, I have a funtion called findText (which I use to help me navigate through drop down lists by typing the first few letters of an item in the drop down list). So this is how I would use it: <input type="text" id="searchCompany" size="1" name="searchCompany" onkeyup="findText(this, Company);"> <asp:dropdownlist ID="Company"...
3
2875
by: John Crowley | last post by:
I've run into a problem where drop down lists are refusing to data bind with the following error on the DataBind() call Specified argument was out of the range of valid values. Parameter name: value Stack trace is showing the error in OnDataBinding event, which I don't hook in the cases where I'm getting this error ArgumentOutOfRangeException: Specified argument was out of the range of valid values Parameter name: value...
7
2292
by: microsoftboy | last post by:
Hi, Using the following selection criteria, I am able to list the data from mysql db, but I would like to provide the following options for users: Select All Data, Select None. I am not sure if this is possiible. Any help would be greatly appreciated. Here's my code <h4>SEARCH</h4> <form action="<?php echo $_SERVER ?>" method = "post" target = "right">
0
9628
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
10292
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
10122
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
6722
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
5368
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
5497
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4031
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
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2860
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.