ASP(C#) : datagrid editing - alert problem
Using asp.net, while updating the data in the datagrid, i wanna ensure that some required fields shudn't b left empty.
For this, i have used the following code:
public void DG_UpdateCommand (object source, DataGridCommandEventArgs e)
{
if(((TextBox)e.Item.Cells[1].Controls[0]).Text==String.Empty)
msg.InnerHtml = "<script>alert('Name cant be blank'); </script>";
else
{
//remaining code
}
}
Now the problem is that if i click edit, leave NAME field blank & click update, it gives alert .. but after this when i click cancel, it cancels editing, again leaving an alert for me to click OK
however on the other hand, if i click edit & then cancel editing without clicking on update, it gives no alert !
can anyone xplain this behaviour?
Here is the CANCEL code:
public void DG_CancelCommand (object source, DataGridCommandEventArgs e)
{
DG.EditItemIndex = -1;
BindData(); //user defined func. to bind data again
}
THANKS.
|