DataGridView - when data changes

amthekkel

Member
Joined
Mar 26, 2009
Messages
14
Programming Experience
Beginner
Hi,

I have a Form called PeopleList which contains a datagridview. I have a peopleDataSet which contains the data obtained from an SQL server from the people table. i can get the datagrid to display the value in the dataset using a table adapter.

I have changed the code recently, now instead of displaying the whole list, i call a form through which users can specify values like name, department etc, and which i pass on to the fill function of the table adapater and it returns the sub set data. This seems to be working fine as well.

What i need to do now is, each time the datagrid displays new data, the application should traverse through the set of records being displayed, if the lastUpdated column (which is datetime) contains dates that are less than 2 days from the current date then display those records in a pop up data grid and alert the user that these records havent been updated recently.

So what i am looking for is a way to know when the data in the datagridview has changed.
_in that event, somehow loop through the records being displayed by the datagrid and then compare the lastUpdated column with todays date
-display those rows that are in the past on a popup datagrid form.

Any suggestions would be much appreciated.

thanks,

abhi
 
You can create a dataview and further filter the table data to only display the records that meet your critera with the DataView.RowFilter method. The results can be bound to your new DataGridView.
 
By this, Tom means to declare a dataview based on your existing datatable and have its filter set to string.Format("[WhateverDateColumn] > #{0}#", DateTime.Now.Date.AddDays(-2).ToShortDateString())

Then if it has any rows, pop up a new datagridview with that as the datasource
 
Problems keeping exisiting formatting

hello all,

I created a dataview which is a subset of a dataset. I am using the dataview as a datasource to a datagridview on another form.

one problem is that I need to hide some of the coumns and two I would like to reorder some of the columns.

is there a way to do this?

thanks for your help.

abhi
 
hello all,

I created a dataview which is a subset of a dataset
A dataview is a filtered view of a datatable, not a dataset. there is a massive difference between a datatable and a dataset

one problem is that I need to hide some of the coumns and two I would like to reorder some of the columns.
the datagridview has a columns collection that you should look at. you can make columns visible = false to hide them, and reordering them is done by use of a numerical property, but I forget which. It may be called Ordinal

Try googling for DataGridViewCOlumnCOllection

is there a way to do this?
It's best to get confident with the difference between a datagridview and a datatable. DT is for holding data, DGV is for showing it. Hiding and reordering is a function of how the data is shown, rather than how it is stored. Hence you'd have had more luck investigating what the DGV can do for you. For a more in depth discussion, read any article you can find on the concept of MVC
 

Latest posts

Back
Top