Home All Groups Group Topic Archive Search About
Author
3 Nov 2007 5:28 PM
Pieter Jansen
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

Author
4 Nov 2007 9:22 AM
Eliyahu Goldin
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


Show quoteHide quote
"Pieter Jansen" <newsSPAMspamTRAP@pitr.net> wrote in message
news:472caf51$0$2379$2e0edba0@news.tweakdsl.nl...
> 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
Are all your drivers up to date? click for free checkup

Author
4 Nov 2007 11:13 AM
P. Jansen
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
Author
4 Nov 2007 12:44 PM
Eliyahu Goldin
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


Show quoteHide quote
"P. Jansen" <nospampj@pitr.net> wrote in message
news:472da402$0$19583$756600cd@news.cambrium.nl...
> 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
Author
4 Nov 2007 7:21 PM
P. Jansen
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
Author
5 Nov 2007 8:52 AM
Eliyahu Goldin
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


Show quoteHide quote
"P. Jansen" <nospampj@pitr.net> wrote in message
news:472e167e$0$22912$756600cd@news.cambrium.nl...
> 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
Author
5 Nov 2007 9:28 PM
P. Jansen
Eliyahu Goldin schreef:
> 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.
>

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
Author
5 Nov 2007 9:43 PM
P. Jansen
Eliyahu Goldin schreef:
> 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.
>

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

Bookmark and Share

Post Thread options