Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Module Development - ViewState ProblemModule Development - ViewState Problem
Previous
 
Next
New Post
9/6/2007 10:16 PM
 

DEV Environment:  VS 2005 (WAP Project), DNN 4.3.4, IIS 6 on Win-XP Pro.

I have an existing module that contains a View Control (abcView.ascx) and an Edit Control (abcEdit.ascx). All is working find but the client now wants to add search capability to the abcView control that will allow the end user to "filter" the records contained in the data grid.  "Should be easy enough" I said to myself.  Well that should have been the first sign of what I was getting myself into... Without tryingto detail the entire code base let me explain where I am and the problem.

The original view form was using a GridView with an associated ObjectDataSource (ODS).  The ODS was bound to the "List..." Method of the Controller.  All was working fine.  Now for the "Easy enough" modifications...

First off, let me say I'm trying to train myself into thinking "re-usable controls" so I figured a search control would be the way to go.  Then I could drop the "Search Control" on the View form, tweak the ODS andmove right along.  With that in mind here is what I did...  Keep in mind because of the problem I've been having it's not in a "reusable state" as of yet.  Once I get it working I will (hopefully) "refactor" it into a reusable control.

1. I added other methods to the SQLDataProvider, DataProvider and Controller to do a list using passed in parameters.

2. Made another user control "abcSearch" that has the text boxes for the user to enter their search criterial.  In the "abcSearch" control there is a method "GetDataSource" that evaluates the user input and determines if the "ListAll..." or "ListFIltered..." method needs to be used.  On intial load the search criteria hasn't been entered yet so the "GetDataSource" method executes the "ListAll..." method.

3. I changed the ODS to bind to the "GetDataSource method" of the "abcSearch" control.

Now the problem...

On initial load of the form the GridView is populated with all records as it should.  After entering the search criteria and clicking "Search" the GridView is still populating all records. Initially I thought it was a postback problem and implemented saving and loading the select criterial to the ViewState but that didn't solve the problem.

After tracing program execution here is what I'm seeing... The search criteria is indeed saved to the  ViewState when the user clicks "Search" but gets "wiped Out" somewhere along the line.  I started tracing through all the functions and found that the following functions are getting called in the following order. NOTE: abcView.ascx is the main view form and abcSearch is the "sub-form", the user control that cointains the search functionality and is embedded on the main view form.

1. abcSearch.ascx - Page_Init function (ViewState intact).
2. abcView.ascx   - Page_Init function (ViewState intact).
3. abcView.ascx   - Page_Load function (ViewState intact).
4. abcSearch.ascx - Page_Load function (ViewState intact).
5. Default.aspx   - Pre_Render function (ViewState is nothing!!!!!).
... the GridView is displayed with all records.

I think I'm missing something.  Any suggestions would be greatly appreciated!!

Chuck R.

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Module Development - ViewState ProblemModule Development - ViewState Problem


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out