HighTechTalks DotNet Forums  

Reload/refresh data in datagrid

ASP.net Data Grid Control microsoft.public.dotnet.framework.aspnet.datagridcontrol


Discuss Reload/refresh data in datagrid in the ASP.net Data Grid Control forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Pieter Jansen
 
Posts: n/a

Default Reload/refresh data in datagrid - 11-03-2007 , 01:28 PM






Hi,

When some control in a page modifies the data displayed in a datagrid
(through an sql update query, of course), how do I refresh the datagrid?

Binding the datagrid doesn't seem to work. Re-binding the datasource
doesn't work. Binding the datasources also doesn't help.

Kind regards,

Pieter

Reply With Quote
  #2  
Old   
Eliyahu Goldin
 
Posts: n/a

Default Re: Reload/refresh data in datagrid - 11-04-2007 , 04:22 AM






Yes, you need to re-bind. If it doesn't work, there is a problem in the way
how you are doing it.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


"Pieter Jansen" <newsSPAMspamTRAP (AT) pitr (DOT) net> wrote

Quote:
Hi,

When some control in a page modifies the data displayed in a datagrid
(through an sql update query, of course), how do I refresh the datagrid?

Binding the datagrid doesn't seem to work. Re-binding the datasource
doesn't work. Binding the datasources also doesn't help.

Kind regards,

Pieter



Reply With Quote
  #3  
Old   
P. Jansen
 
Posts: n/a

Default Re: Reload/refresh data in datagrid - 11-04-2007 , 06:13 AM



Eliyahu Goldin schreef:
Quote:
Yes, you need to re-bind. If it doesn't work, there is a problem in the way
how you are doing it.
How do I go around debugging this? Does the datagrid emit trace/warnings
somewhere?

Do you have an example on how this should be done officially?

Kind regards,

Pieter


Reply With Quote
  #4  
Old   
Eliyahu Goldin
 
Posts: n/a

Default Re: Reload/refresh data in datagrid - 11-04-2007 , 07:44 AM



What do you use for databinding: DataSource or DataSourceID?

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


"P. Jansen" <nospampj (AT) pitr (DOT) net> wrote

Quote:
Eliyahu Goldin schreef:
Yes, you need to re-bind. If it doesn't work, there is a problem in the
way how you are doing it.

How do I go around debugging this? Does the datagrid emit trace/warnings
somewhere?

Do you have an example on how this should be done officially?

Kind regards,

Pieter



Reply With Quote
  #5  
Old   
P. Jansen
 
Posts: n/a

Default Re: Reload/refresh data in datagrid - 11-04-2007 , 02:21 PM



Eliyahu Goldin schreef:
Quote:
What do you use for databinding: DataSource or DataSourceID?
DataSourceID

It works when I insert a new row
It doesn't work when I update an existing row.

The code I use to refresh:

myGrid.DataSourceID = null;
myGrid.DataSourceID = "mydatasource";
myGrid.DataBind();

Kind regards,

Pieter


Reply With Quote
  #6  
Old   
Eliyahu Goldin
 
Posts: n/a

Default Re: Reload/refresh data in datagrid - 11-05-2007 , 03:52 AM



Run the select statement of your datasource:

mydatasource.Select(System.Web.UI.DataSourceSelect Arguments.Empty);

No need to rebind the grid, it should pick up the changes automatically.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


"P. Jansen" <nospampj (AT) pitr (DOT) net> wrote

Quote:
Eliyahu Goldin schreef:
What do you use for databinding: DataSource or DataSourceID?

DataSourceID

It works when I insert a new row
It doesn't work when I update an existing row.

The code I use to refresh:

myGrid.DataSourceID = null;
myGrid.DataSourceID = "mydatasource";
myGrid.DataBind();

Kind regards,

Pieter



Reply With Quote
  #7  
Old   
P. Jansen
 
Posts: n/a

Default Re: Reload/refresh data in datagrid - 11-05-2007 , 04:28 PM



Eliyahu Goldin schreef:
Quote:
Run the select statement of your datasource:

mydatasource.Select(System.Web.UI.DataSourceSelect Arguments.Empty);

No need to rebind the grid, it should pick up the changes automatically.

I do need to rebind the grid, otherwise no refresh will be seen.

The problem lies somewhere else. The SQL statements are executed, but
the data is not committed into the database until after I trigger a
Page_Load. Some autocommit mechanism seems to be failing, but only on
UPDATE queries. INSERT statements go fine.

I'll let you know if I find out what's going wrong with the updates.

Kind regards,

Pieter


Reply With Quote
  #8  
Old   
P. Jansen
 
Posts: n/a

Default Re: Reload/refresh data in datagrid - 11-05-2007 , 04:43 PM



Eliyahu Goldin schreef:
Quote:
Run the select statement of your datasource:

mydatasource.Select(System.Web.UI.DataSourceSelect Arguments.Empty);

No need to rebind the grid, it should pick up the changes automatically.

Solved:

http://sqlite.phxsoftware.com/forums/p/231/863.aspx#863

"# You cannot have any active datareaders open on a connection when you
commit the transaction. All datareaders must be disposed of before you
can rollback. In the case of a commit, if you commit when a datareader
is open, the actual commit is delayed until all datareaders are disposed
and then the commit occurs."

I did not explicitly close the datareaders, thus the commits were delayed.

Thanks for the help!

Kind regards,

Pieter


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.