namco
namco

Reputation: 6338

how to catch TableNewRow Event of DataTable while loading data

I want to catch the TableNewRow event everytime when an adapter adds a new row to a DataTable.

Are there any ways to catch the NewRow event of a DataTable?

string sql = "SELECT * FROM t_table";
command.CommandText = sql;
adapter.CommandText = command;
DataTable dt = new DataTable();
adapter.Fill(dt);

i have tried this code below but it doesnt work..

dt.TableNewRow += new DataTableNewRowEventHandler(dt_TableNewRow); 
private void dt_TableNewRow(object sender, DataTableNewRowEventArgs e)
{
       MessageBox.Show("Event Raised...");
}

Upvotes: 0

Views: 3137

Answers (1)

Omar
Omar

Reputation: 16623

You can use the TableNewRow event.

EDIT:

As said p.cambell, you should implement the handler as here.

Upvotes: 1

Related Questions