all groups > asp.net datagrid control > november 2007 >
You're in the

asp.net datagrid control

group:

Reload/refresh data in datagrid


Reload/refresh data in datagrid Pieter Jansen
11/3/2007 6:28:02 PM
asp.net datagrid control:
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,

Re: Reload/refresh data in datagrid Eliyahu Goldin
11/4/2007 11:22:45 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


[quoted text, click to view]

Re: Reload/refresh data in datagrid P. Jansen
11/4/2007 12:13:09 PM
Eliyahu Goldin schreef:
[quoted text, click to view]

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,

Re: Reload/refresh data in datagrid Eliyahu Goldin
11/4/2007 2:44:44 PM
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


[quoted text, click to view]

Re: Reload/refresh data in datagrid P. Jansen
11/4/2007 8:21:41 PM
Eliyahu Goldin schreef:
[quoted text, click to view]

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,

Re: Reload/refresh data in datagrid Eliyahu Goldin
11/5/2007 10:52:49 AM
Run the select statement of your datasource:

mydatasource.Select(System.Web.UI.DataSourceSelectArguments.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


[quoted text, click to view]

Re: Reload/refresh data in datagrid P. Jansen
11/5/2007 10:28:40 PM
Eliyahu Goldin schreef:
[quoted text, click to view]

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,

Re: Reload/refresh data in datagrid P. Jansen
11/5/2007 10:43:38 PM
Eliyahu Goldin schreef:
[quoted text, click to view]

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,

AddThis Social Bookmark Button