Yara
Yara

Reputation: 4565

ASP.NET GridView how to cancel update

I have GridView with connected SqlDataSource and I want cancel updating row when my condition is false in OnRowUpdating event? How to do it? Thank you.

Upvotes: 3

Views: 5301

Answers (1)

Flob
Flob

Reputation: 128

try

protected void Page_Load(object sender, EventArgs e)
    {
        GridView1.RowUpdating += new GridViewUpdateEventHandler(GridView1_RowUpdating);
    }

    void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
          e.Cancel = true;
    }

Upvotes: 5

Related Questions