Database Reference
In-Depth Information
protected void FormView1_ItemUpdated(object sender,
System.Web.UI.WebControls.FormViewUpdatedEventArgs e)
{
//Display the update status and update the GridView control
display
GridView1.DataBind();
lblStatus.Text
=
"The class schedule is updated.";
}
3. To display the status of the insert action, add the following code for the FormView1_
ItemInserted method as shown in Figure 9.37:
protected void FormView1_ItemInserted(object sender,
System.Web.UI.WebControls.FormViewInsertedEventArgs e)
{
//Display the insert status and update the GridView control
display
GridView1.DataBind();
lblStatus.Text
=
"The new class is added.";
}
4. To display the status of the delete action, add the following code for the FormView1_
ItemDeleted method as shown in Figure 9.37:
protected void FormView1_ItemDeleted(object sender,
System.Web.UI.WebControls.FormViewDeletedEventArgs e)
{
//Display the delete status and update the GridView control
display
GridView1.DataBind();
lblStatus.Text
=
"The class is deleted.";
}
5. To update the GridView control, add the following code for the SqlDataSource2_
Selecting method as shown in Figure 9.37:
protected void SqlDataSource2_Selecting(object sender,
SqlDataSourceSelectingEventArgs e)
{
//Update the GridView control display
GridView1.DataBind();
}
6. he actions update, insert, and delete are triggered by clicking the Update, Delete, and
Insert links. When clicking one of these links, a corresponding event will be generated.
he event handler onItemInserted, onItemUpdated, or onItemDeleted is used to process
a related event. As shown in Figure 9.38, you need to modify the Default.aspx ile by add-
ing three event handlers:
onItemInserted
=
"FormView1_ItemInserted"
onItemUpdated
=
"FormView1_ItemUpdated"
onItemDeleted
=
"FormView1_ItemDeleted"