// Get the country for the row being edited. For this example, the // country is contained in the seventh column (index 6). String country = CustomersGridView.Rows[e.NewEditIndex].Cells[6].Text; // For this example, cancel the edit operation if the user attempts // to edit the record of a customer from the Unites States. if (country == "USA") { // Cancel the edit operation. e.Cancel = true; Message.Text = "You cannot edit this record."; } else { Message.Text = ""; }
}
Protected Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing GridView1.EditIndex = e.NewEditIndex 'Call gridview1_databind() TextBox1.Text = GridView1.Rows(e.NewEditIndex).Cells(1).Text.ToString Call gridview1_databind() End Sub
{
// Get the country for the row being edited. For this example, the
// country is contained in the seventh column (index 6).
String country = CustomersGridView.Rows[e.NewEditIndex].Cells[6].Text; // For this example, cancel the edit operation if the user attempts
// to edit the record of a customer from the Unites States.
if (country == "USA")
{
// Cancel the edit operation.
e.Cancel = true;
Message.Text = "You cannot edit this record.";
}
else
{
Message.Text = "";
}
}
GridView1.EditIndex = e.NewEditIndex
'Call gridview1_databind() TextBox1.Text = GridView1.Rows(e.NewEditIndex).Cells(1).Text.ToString
Call gridview1_databind() End Sub