MessageBox can be displayed to user if UpdateRow cannot be invoked in a specific case by using ClientAction engine in WebGrid. ClientAction engine is attached per grid instance and designed to bridge the gaps between client and server.
In this topic, you will learn the basic thing on how to display the MessageBox in WebGrid if the UpdateRow can not be invoked.
To display MessageBox in WebGrid
- Go to WebGrid properties, server side event.
- Attach the WebGrid UpdateRow event into the WebGrid.
- Inside of the condition, use ClientAction engine to do a client side Alert.
C# Copy Code private void WebGrid1_UpdateRow(object sender, ISNet.WebUI.WebGrid.RowEventArgs e) { if (e.Row.Cells.GetNamedItem("Country").Text == "UK") { // Display alert to user WebGrid1.ClientAction.Alert("You can't update this row!"); DataRowView drv = (DataRowView)e.Row.DataRow; drv.Row.RejectChanges(); e.ReturnValue = false; } }
- Run the project.