Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 18th, 2008, 03:12 PM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
Default Calendar control clears GridView

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?

 
Old April 18th, 2008, 03:57 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

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
================================================== =========
 
Old April 18th, 2008, 10:51 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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
 
Old April 19th, 2008, 09:12 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

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
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
File Control clears on postback. aniruddhap HTML Code Clinic 1 January 2nd, 2008 03:33 AM
Calendar control cJeffreywang ASP.NET 2.0 Basics 2 July 4th, 2007 01:05 PM
Calendar Control Brendan Bartley Access 4 September 8th, 2006 03:58 AM
Calendar Control with Tab Control Slicemahn Access 1 June 12th, 2006 10:35 PM
Calendar Control stu9820 ASP.NET 1.0 and 1.1 Basics 3 January 28th, 2004 11:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.