|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Reload/refresh data in datagridHi,
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 Yes, you need to re-bind. If it doesn't work, there is a problem in the way
how you are doing it. -- Show quoteHide quoteEliyahu Goldin, Software Developer Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net "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 Eliyahu Goldin schreef:
> Yes, you need to re-bind. If it doesn't work, there is a problem in the way How do I go around debugging this? Does the datagrid emit trace/warnings > how you are doing it. somewhere? Do you have an example on how this should be done officially? Kind regards, Pieter What do you use for databinding: DataSource or DataSourceID?
-- Show quoteHide quoteEliyahu Goldin, Software Developer Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net "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 Eliyahu Goldin schreef:
> What do you use for databinding: DataSource or DataSourceID? DataSourceIDIt 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 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. -- Show quoteHide quoteEliyahu Goldin, Software Developer Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net "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 Eliyahu Goldin schreef:
> Run the select statement of your datasource: I do need to rebind the grid, otherwise no refresh will be seen.> > mydatasource.Select(System.Web.UI.DataSourceSelectArguments.Empty); > > No need to rebind the grid, it should pick up the changes automatically. > 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 Eliyahu Goldin schreef:
> Run the select statement of your datasource: Solved:> > mydatasource.Select(System.Web.UI.DataSourceSelectArguments.Empty); > > No need to rebind the grid, it should pick up the changes automatically. > 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
Why Does This Not Work?
Datagrid default date format Programattically setting gridview to edit mode GridView - Hyperlink Hiding grid columns based on some value in row DataView Borders Editing/Deleting/Inserting Records using ASPxGridView edit template to edit record with null field Controlstyle How do I remove Datagrid Spacing? |
|||||||||||||||||||||||