473,385 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

nested dropdownlist loses values - only in one instance

I have a page that has two copies of the same control in it. The
control is:

BorrowerControl

the two references to it in the page are

bControl1
cobControl1

The control contains a dropdownlist that is populated from xml. I only
bind this data on page_load, not on subsequent postbacks (shouldn't
need to). Code to bind (where this.States is a dataset on the page)
is:

foreach(DataRow d in this.States.Tables[0].Rows)
{
string txt = d["abv"].ToString();
string val = d["abv"].ToString();
li = new ListItem(txt, val);
control.Items.Add(li);
}
control.DataBind();

I'm getting some REALLY strange behavior. The dropdownlist in
bControl1 maintains its values on postback, but the dropdownlist in
cobControl1 does not. I haven't found anything that says I can't have
multiple copies of the same control on the page, or that would explain
this type of erratic behavior. Can someone shed some light on this
situation? I can provide more detail if necessary. And no, I don't
have enableViewState = false on either instance of the control.

Sincerely,

Bryan Ax
Nov 18 '05 #1
5 2338
Hi,

Is that custom server control? if so, did you implement IStateManager,
and how.

by the way why you are using DataBind. you add explicitly items to items
collection. you don't bind your control to any datasource.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2
It's a user control (.ascx), not a custom server control. It does use
a custom implementation of viewstate, saving to a database. However,
that doesn't explain to me why one instance of it would work ok, and
the other not.

Databind was commented out from an earlier attempt. Forgot to include
that.

Bryan

Natty Gur <na***@dao2com.com> wrote in message news:<#F*************@TK2MSFTNGP10.phx.gbl>...
Hi,

Is that custom server control? if so, did you implement IStateManager,
and how.

by the way why you are using DataBind. you add explicitly items to items
collection. you don't bind your control to any datasource.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #3
More info....

I removed the custom viewstate implementation, just went back to
having the page extend from System.Web.UI.Page. Still didn't work. Now
the page stores viewstate just like any other, and it is still not
functional.

Natty Gur <na***@dao2com.com> wrote in message news:<#F*************@TK2MSFTNGP10.phx.gbl>...
Hi,

Is that custom server control? if so, did you implement IStateManager,
and how.

by the way why you are using DataBind. you add explicitly items to items
collection. you don't bind your control to any datasource.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #4
OK, I think I've identified where the problem happens, but I don't
understand the why. Hopefully, someone can fill me in.

The following code fails. All I'm trying to do is populate two
dropdownlists from the same set of items (in my real case, a list of
states, but this is just a test).

When I execute the following, the first one fills just fine, but the
second one does not, i.e. the line this.loadDdl(this.DropDownList2)
does not populate the dropdownlist with items. Can someone please
explain to me why it doesn't work? I'm really missing something that
must be obvious.
private void loadDdl(DropDownList control)
{
ListItem li = new ListItem("Hello", "world");
control.Items.Add(li);
li = new ListItem("Goo", "ber");
control.Items.Add(li);
li = new ListItem("gee", "whiz");
control.Items.Add(li);
}

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (! this.Page.IsPostBack)
{
this.loadDdl(this.DropDownList1);
this.loadDdl(this.DropDownList2);
}
}
Natty Gur <na***@dao2com.com> wrote in message news:<#F*************@TK2MSFTNGP10.phx.gbl>...
Hi,

Is that custom server control? if so, did you implement IStateManager,
and how.

by the way why you are using DataBind. you add explicitly items to items
collection. you don't bind your control to any datasource.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #5
Actually, my last post was incorrect. That did work OK - just hadn't
recompiled.

However, this time I have figured it out. On the user control that's
problematic, I'm removing a validation control, i.e.

this.Controls.Remove(this.ValidationControl);

during the page_load event.

That line of code causes the problem. No clue as to why removing one
control would affect others on the page, and ONLY dropdownlists on the
page (other controls like textboxes are not affected). The validation
control does not apply to the dropdownlist at all.

I tried moving that line to prerender, still broke it. I've gotten
around it by just setting the enabled of it to false, but it still
doesn't explain the why to me.

Anyone?

ba*@kleinbuendel.com (Bryan Ax) wrote in message news:<7a**************************@posting.google. com>...
I have a page that has two copies of the same control in it. The
control is:

BorrowerControl

the two references to it in the page are

bControl1
cobControl1

The control contains a dropdownlist that is populated from xml. I only
bind this data on page_load, not on subsequent postbacks (shouldn't
need to). Code to bind (where this.States is a dataset on the page)
is:

foreach(DataRow d in this.States.Tables[0].Rows)
{
string txt = d["abv"].ToString();
string val = d["abv"].ToString();
li = new ListItem(txt, val);
control.Items.Add(li);
}
control.DataBind();

I'm getting some REALLY strange behavior. The dropdownlist in
bControl1 maintains its values on postback, but the dropdownlist in
cobControl1 does not. I haven't found anything that says I can't have
multiple copies of the same control on the page, or that would explain
this type of erratic behavior. Can someone shed some light on this
situation? I can provide more detail if necessary. And no, I don't
have enableViewState = false on either instance of the control.

Sincerely,

Bryan Ax

Nov 18 '05 #6

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

Similar topics

1
by: pete | last post by:
Hello all, I'l displaying a dropdownlist inside a datagrid. The problem comes when I try to get the values the user chose on postback. If I rebind the datagrid, the values of the dropdownlist...
10
by: Sacha Korell | last post by:
I'm trying to load a drop-down list with all DropDownList control names from another page. How would I be able to find those DropDownList controls? The FindControl method will only find a...
6
by: Lionel Slade | last post by:
Hi, I've bound some drop down lists to a dataset, but if the iexplorer window is resized the contents of the lists are lost? Why is this happening? AutoPostback is set to true.
1
by: Roffers | last post by:
Okay I have a parent page, we'll call it parent.aspx and it holds the following two user controls <uc1:Box1 id="Box1" runat="server"></uc1:Box1<----THIS CONTAINS A DROP DOWN LIST <br>...
2
by: brad | last post by:
Group, I'm using Visual Studio 2003 to create an ASP.NET 1.1 project which contains nested server user controls in order to create a tree-like hierarchy. The tree is a sort of question and...
0
by: sgtmarcjones | last post by:
How do I access a dropdownlist that is nested within a Formview ItemTemplate Gridview Template? I want to see a label (lgbTimeKeep ! TextValue of ddlName dropdownlist) instead of a dropdownlist...
0
by: sharonrao123 | last post by:
hello all, I have a parent gridview company and in this one a nested gridview people, Is it possible to allow the user to select one row or multiple rows from the people gridview using a check box...
5
by: John Kotuby | last post by:
Hi all, After more than a year programming with ASP.NET 2.0 and VB I am still finding it difficult to leave some habits from classic ASP behind. this is particularly true with cross-page posting....
6
by: RobertTheProgrammer | last post by:
Hi folks, Here's a weird problem... I have a nested GridView setup (i.e. a GridView within a GridView), and within the nested GridView I have a DropDownList item which has the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.