Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid doesn't keep data between page loads

Status
Not open for further replies.

iambrunner

IS-IT--Management
Feb 1, 2005
3
US
Hi all,

I'm pretty new to ASP.Net. I have a datagrid that is bound to some data at runtime on the first page load. EnableViewState is set to true for the datagrid. My problem is that the data in the datagrid disappears between page loads. If I repopulate the datagrid on each page load, I won't be able to retrieve the textbox values to update the DB, AFAIK.

The code is here:
Any help would be much appreciated. Thank you in advance.
 
What happens if you step through your code in the debugger?

Try putting a break in the init function, then refresh the page. Look at the state of the datagrids data at the top, adn watch to see where it gets overwritten...

Why are you creating an SQL connection and opening it outside the if !(IsPostBack), this is (albeit a minor one) waste of time, as if the page is on a postback, you open a connection for nothing..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top