By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,760 Members | 1,644 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,760 IT Pros & Developers. It's quick & easy.

Refresh a datagrid

P: n/a
Cat
If you have a datagrid with an underlying dataset and rows are added to the
dataset during a program run, how do you get the datagrid to update itself
to repflect the changes in the underlying dataset? I've tried Update() and
Refresh() but these don't seem to work. Only thing that works is rebinding
the datset to the datagrid control, but this doesn't seem to be quite right.

Cat
Nov 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Cat,

What are you binding the data grid to? Are you binding to the table, or
to the data set? It seems like the view you have on the table is different
from what you are modifying.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Cat" <lo***********@yahoo.co.uk> wrote in message
news:Oz**************@TK2MSFTNGP11.phx.gbl...
If you have a datagrid with an underlying dataset and rows are added to the dataset during a program run, how do you get the datagrid to update itself
to repflect the changes in the underlying dataset? I've tried Update() and
Refresh() but these don't seem to work. Only thing that works is rebinding
the datset to the datagrid control, but this doesn't seem to be quite right.
Cat

Nov 16 '05 #2

P: n/a
Have you comitted the new data [AcceptChanges], the datagrid may be
excluding the 'Added' RowState rows that you have just added.
"Cat" <lo***********@yahoo.co.uk> wrote in message
news:Oz**************@TK2MSFTNGP11.phx.gbl...
If you have a datagrid with an underlying dataset and rows are added to the dataset during a program run, how do you get the datagrid to update itself
to repflect the changes in the underlying dataset? I've tried Update() and
Refresh() but these don't seem to work. Only thing that works is rebinding
the datset to the datagrid control, but this doesn't seem to be quite right.
Cat

Nov 16 '05 #3

P: n/a
Cat

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:ut**************@tk2msftngp13.phx.gbl...
Cat,

What are you binding the data grid to? Are you binding to the table, or to the data set? It seems like the view you have on the table is different from what you are modifying.


Hi

Basically I have a DataSet containing one DataTable. The DataGrid has the
DataTable as it's data source. I've done this at design time. During loading
of the form that the DataGrid is on, rows are added to the DataTable.
However, these aren't reflected in the DataGrid until I set the DataTable to
be it's source (again, although this has already been done at design time).
I need to know the correct procedure for updating my DataGrid, rather than
setting it's data source to null then to the DataTable again. This certainly
works, but I'm not sure it's the correct way of doing it (correct me if I'm
wrong).

Thanks for your help.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Cat" <lo***********@yahoo.co.uk> wrote in message
news:Oz**************@TK2MSFTNGP11.phx.gbl...
If you have a datagrid with an underlying dataset and rows are added to

the
dataset during a program run, how do you get the datagrid to update itself to repflect the changes in the underlying dataset? I've tried Update() and Refresh() but these don't seem to work. Only thing that works is rebinding the datset to the datagrid control, but this doesn't seem to be quite

right.

Cat


Nov 16 '05 #4

P: n/a
Cat

"Colin Stutley" <co***@ws.com.au> wrote in message
news:OX**************@TK2MSFTNGP10.phx.gbl...
Have you comitted the new data [AcceptChanges], the datagrid may be
excluding the 'Added' RowState rows that you have just added.


I have tried calling AcceptChanges on my DataTable then calling Refresh on
my DataGrid but this doesn't seem to work.
"Cat" <lo***********@yahoo.co.uk> wrote in message
news:Oz**************@TK2MSFTNGP11.phx.gbl...
If you have a datagrid with an underlying dataset and rows are added to

the
dataset during a program run, how do you get the datagrid to update itself to repflect the changes in the underlying dataset? I've tried Update() and Refresh() but these don't seem to work. Only thing that works is rebinding the datset to the datagrid control, but this doesn't seem to be quite

right.

Cat


Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.