Subject: Calendar control clears GridView
Posted By: snufse Post Date: 4/18/2008 3:12:51 PM
I have a page where I can select a date using the calendar control. The calendar control is placed in the same area as a grid view. If there is a grid view displayed and user selects a new date, the calendar control clears the grid view. Is there a way to preserve the grid view in this case?

Reply By: dparsons Reply Date: 4/18/2008 3:57:58 PM
You need to rebind your GridView on post backs.  I imagine your code probably looks something like this:

protected void Page_Load(object sender, EventArgs e)
{
   if(!Page.IsPostback)
   {
     //Bind Grind
   }
}

Problem is, when a user selects a date, your grid is never bound again.

hth.
-Doug

===========================================================
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
===========================================================
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
===========================================================
Reply By: planoie Reply Date: 4/18/2008 10:51:04 PM
Shouldn't the GridView be maintaining its own state and rebuild itself with the data previously bound to it?  This should be the default behavior.  Is EnableViewState turned off for the gridview?

-Peter
peterlanoie.blog
Reply By: dparsons Reply Date: 4/19/2008 9:12:23 AM
Obviously my statement is based on what little detail was provided in the original comment, so I am making an assumption.

As Peter said the Grid should maintain its state through round trips to the server but without seeing any of your code, it is hard to say what the true problem is.

hth.
-Doug

===========================================================
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
===========================================================
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
===========================================================

Go to topic 70716

Return to index page 1