views:

121

answers:

2

Hi

I am trying to fix somebody elses code and this is my first ASP.NET dataVIEW experiance, basically I want to check that a textbox has a value, The DataVIEW has been coded so that on the "add/update" an ok/cancel button is used.

In the Rowcommmand I have detected the update successfully, found the text box, and varified the contents ..... but now I can't cancel the RowComand .. is there any way to do this ?

Thanks in advance

A: 

If you use the RowUpdating event you can set the Cancel property in the EventArgs object (http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridviewupdateeventargs%5Fmembers.aspx)

Keith K
+3  A: 

Try this approach instead, using the RowUpdating event:

protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
    //Do the check.
    //IF check succeeds do nothing
    //IF check fails do this:
    e.Cancel = true; //Cancels the impending update.
}
Matthew Jones
Thank you ... not exactly what I asked for, but told me me what I should have asked for :-)
spacemonkeys