Viewstate of Controls Within WebControl

Q

quiggle

Howdy!

I have created a web control (ExplanationControl) that contains a datagrid,
and a dropDownList. Both of these controls get populated with data, and are
bound in the Page_Load event of the webcontrol itself. I have a couple of
issues that I am facing, which I believe are related to veiwstate...

1. When a value is selected in the dropDownList, and then the page is
saved, when the page reloads, that same value is selected.
2. When one of the values in the dataGrid is deleted (using a link button
with the commandName of Delete) when the page reloads, the item is still
present. If the page is reloaded again, the item disappears.

I have set enableViewState to false for as many things I can think of....The
page, the form, the asp:Table, the custom webcontrol and the controls with
the web control.

One other tidbit that might be of some use for solving this is that I am
dynamically adding the ExplainControl to the asp:Table dynamically in the
Page_Load of the actual page all this stuff sits on.

Any help would be greatly appreciated...I have been racking my brain over
this for a few days now!

Thanks!

Aimee
 
S

Scott Mitchell [MVP]

quiggle said:
I have created a web control (ExplanationControl) that contains a datagrid,
and a dropDownList. Both of these controls get populated with data, and are
bound in the Page_Load event of the webcontrol itself. I have a couple of
issues that I am facing, which I believe are related to veiwstate...

1. When a value is selected in the dropDownList, and then the page is
saved, when the page reloads, that same value is selected.

This is the intended behavior. This is NOT due to view state. I
discuss this in an upcoming article of mine on view state that will be
on the ASP.NET Dev Center on MSDN [http://msdn.microsoft.com/asp.net/].
If you want, drop me an email [[email protected]] and I'll
email you the draft I submitted (a Word document), if you like.
2. When one of the values in the dataGrid is deleted (using a link button
with the commandName of Delete) when the page reloads, the item is still
present. If the page is reloaded again, the item disappears.

My guess would be that you're not rebinding the data to the DataGrid
after you delete the record. If you are, then chances are you're not
closing the connection after deleting the row from DataGrid, but before
rebinding the data...

Let me know if this works for you...

Thanks.

--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top