GridView1_RowUpdating

  • Thread starter Thread starter Bhagya
  • Start date Start date
B

Bhagya

How do i use the GridView1_RowUpdating event?? Can someone please
post
the C# code for this...Thanks in advance
 
U need to add a event Handler for the RowUpdating Event in the
OnInit() Event Handler of the Page. After that add the code in the
RowUpdating EventHandler (for e.g. setting the format of data to be
stored in the table, Html encoding the data to be stored into the
table to prevent cross site scripting attacks etc...)

protected override void OnInit(EventArgs e)
{
base.OnInit(e);
GridView1.RowUpdating += new
GridViewUpdateEventHandler(GridView1_RowUpdating);
}

void GridView1_RowUpdating(Object sender, GridViewUpdateEventArgs e)
{
foreach (DictionaryEntry entry in e.NewValues)
{
e.NewValues[entry.Key] =
Server.HtmlEncode(entry.Value.ToString());
}
}

The RowUpdating Event occurs after the Update button on the Datagrid
is clicked and before the row is updated in the database (underlying
data source)
RowUpdated Event occurs after the row has been updated in the
underlying datasource.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top