开发者

Cancel a Datagrid rowcommand

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


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.
}


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_members.aspx)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜