views:

135

answers:

1

I wont to create a User Control based in gridview that have the edit add delete incorporate, the problem is these:

In the admin part of my web site i have to repeat the same action for view add delete update the data for different datasource.

I wont to create a generic gridview that have incorporate these action.

The gridview can take a xml file for configure him self dependently of the request for desplay the data.

Any ideas how i can do it?

A: 

The standard gridview enables the add delete and update functions that you are looking for. If you would like to perform extra actions, such as adding, deletinga and updating to an additional data source, the standard GridView has events that enable this.

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview_events.aspx

Look at the GridViewUpdatedEventArgs parameter in the following event handler. It contains the data keys, the OldValues and the NewValues. Everything that you need to either log your changes or replicate them in an additional datasource.

protected void CustomersGridView_RowUpdated(Object sender, GridViewUpdatedEventArgs e)
{

if(e.Exception == null)
{
     //Perform your additional update to your other datasource here


}
else
{
  e.ExceptionHandled = true;
  Message.Text = "An error occurred while attempting to update the row.";
}

}

Daniel Dyson