473,626 Members | 3,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Tab les[0].Rows)
{
string txt = d["abv"].ToString();
string val = d["abv"].ToString();
li = new ListItem(txt, val);
control.Items.A dd(li);
}
control.DataBin d();

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 2345
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******* ******@TK2MSFTN GP10.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.P age. 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******* ******@TK2MSFTN GP10.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(th is.DropDownList 2)
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(DropDow nList control)
{
ListItem li = new ListItem("Hello ", "world");
control.Items.A dd(li);
li = new ListItem("Goo", "ber");
control.Items.A dd(li);
li = new ListItem("gee", "whiz");
control.Items.A dd(li);
}

private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
if (! this.Page.IsPos tBack)
{
this.loadDdl(th is.DropDownList 1);
this.loadDdl(th is.DropDownList 2);
}
}
Natty Gur <na***@dao2com. com> wrote in message news:<#F******* ******@TK2MSFTN GP10.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.R emove(this.Vali dationControl);

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*@kleinbuende l.com (Bryan Ax) wrote in message news:<7a******* *************** ****@posting.go ogle.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.Tab les[0].Rows)
{
string txt = d["abv"].ToString();
string val = d["abv"].ToString();
li = new ListItem(txt, val);
control.Items.A dd(li);
}
control.DataBin d();

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
3150
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 are all set back to their original values. If I do not rebind the datagrid, I don't seem to have access to the dropdownlist at all. Code fragment:
10
5301
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 certain control by id, but I want to find all controls of a certain type (DropDownList in this case). Is there an easier way than to get a control count of the page, loop through all controls on that page, examine their type and, if they're a...
6
1187
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
1670
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> <uc1:Box2 id="Box2" runat="server"></uc1:Box2<----THIS CONTAINS A DATALIST In Box1, I have a dropdown list that gets selected and should set
2
2404
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 answer dialog. The user answers a question, and the next subquestion appears (using dynamic html display:none|block) depending on his answer.
0
5940
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 in the FormView ItemTemplate Nested Gridview ddlName ItemTemplate. My label is named lgvTimeKeep and the dropdownlist name is ddlName. Thanks!
0
4657
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 and also get the datakey (in my case personid) of the the rows selected. Please point me in the right direction. This is what i have so far but i have problem accessing the child gridview in the button click event Cheers, Shilpa. <asp:GridView...
5
4109
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. My site uses Master pages and user controls. On an Advanced Search page I have numerous entry boxes and listboxes (keywords, categories, etc.) which are primarily standard HTML. I post this page to a different page which lists results and...
6
5749
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 OnSelectedIndexChanged event set on it. This triggers just fine, but within the codebehind of the OnSelectedIndexChanged event, I need to scan through all the entries in the nested GridView (to see if the user changed a value to an already existing value in the...
0
8707
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
8641
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
6125
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
5575
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
4093
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
4202
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2628
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
1
1812
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1512
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.