Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > 2nd pair of eyes needed for DropDownList question & saving state

Reply
Thread Tools

2nd pair of eyes needed for DropDownList question & saving state

 
 
Steve Hershoff
Guest
Posts: n/a
 
      08-06-2007
Hi everyone,

I'm not sure that what I'm trying can't be done (at least, not how I'm
trying to do it) but I was hoping for confirmation and possible suggestions
on a future approach.

We have created a specialized version of the DropDownList class. An
abbreviated version reads like this:

public class MyDropDownList: System.Web.UI.WebControls.DropDownList
{
private bool _IsChanged;
....
}

The _IsChanged member is used as a "dirty" flag. Here's an overriden method
that uses it:

protected override void OnSelectedIndexChanged( EventArgs e )
{
_IsChanged = true;
base.OnSelectedIndexChanged(e);
}

If I add my control to an ascx page and give it an autopostback property,
the OnSelectedIndexChanged is fired as expected when the dropdown value
changes.

But modifying the _IsChanged property....does that do any good? After the
page has been reposted I don't believe the member variable's value will be
remembered for future use, even if viewstate has been set on the control.
At least that's how it appears to be in this instance. (I'm using VS 2003
for what it's worth)

If this is the case, would you have any suggestions on how to force a
control to remember internal values between page posts, if possible? Thanks
very much.


 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      08-06-2007
Using ViewState for the isChanged e.g make it a property which uses
ViewState collection under the hood. Note that when making such persistence,
you should also think when you reset ischanged information so that it's not
true till the end of the world when once set

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net


"Steve Hershoff" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi everyone,
>
> I'm not sure that what I'm trying can't be done (at least, not how I'm
> trying to do it) but I was hoping for confirmation and possible
> suggestions on a future approach.
>
> We have created a specialized version of the DropDownList class. An
> abbreviated version reads like this:
>
> public class MyDropDownList: System.Web.UI.WebControls.DropDownList
> {
> private bool _IsChanged;
> ....
> }
>
> The _IsChanged member is used as a "dirty" flag. Here's an overriden
> method that uses it:
>
> protected override void OnSelectedIndexChanged( EventArgs e )
> {
> _IsChanged = true;
> base.OnSelectedIndexChanged(e);
> }
>
> If I add my control to an ascx page and give it an autopostback property,
> the OnSelectedIndexChanged is fired as expected when the dropdown value
> changes.
>
> But modifying the _IsChanged property....does that do any good? After the
> page has been reposted I don't believe the member variable's value will be
> remembered for future use, even if viewstate has been set on the control.
> At least that's how it appears to be in this instance. (I'm using VS 2003
> for what it's worth)
>
> If this is the case, would you have any suggestions on how to force a
> control to remember internal values between page posts, if possible?
> Thanks very much.
>



 
Reply With Quote
 
 
 
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      08-06-2007
"Steve Hershoff" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> If this is the case, would you have any suggestions on how to force a
> control to remember internal values between page posts, if possible?


How are you populating the DropDownList...?


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

 
Reply With Quote
 
Steve Hershoff
Guest
Posts: n/a
 
      08-06-2007
Hi,

Thanks for the reply.

I'm using a HashTable as the datasource. The property is set like this:

public object HTSource
{
get{return _HTSource; }
set
{
if(value is Hashtable)
{
_HTSource = value;
this.DataSource = (Hashtable)_HTSource;
}
}
}

What's interesting is if I don't set the autopostback property, the
_IsChanged value is available in subsequent postbacks. But if autopostback
is true, it the value is available for only the auto postback and not
subsequent postbacks. If you need more information by all means ask.



"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:en%(E-Mail Removed)...
> "Steve Hershoff" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> If this is the case, would you have any suggestions on how to force a
>> control to remember internal values between page posts, if possible?

>
> How are you populating the DropDownList...?
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
another pair of eyes... =?Utf-8?B?cm9kY2hhcg==?= ASP .Net 0 07-12-2006 09:46 PM
J2ee: need another pair of eyes. DaLoverhino Java 1 11-22-2005 07:48 PM
Re: need second pair of eyes: databinder.eval problem Phil Winstanley [Microsoft MVP ASP.NET] ASP .Net 3 06-21-2004 06:24 PM
need second pair of eyes: databinder.eval problem darrel ASP .Net 0 06-21-2004 03:16 PM



Advertisments