E-Book Gallery for Microsoft Technologies

Download content for ASP.NET, Office, SQL Server, Windows Azure, SharePoint Server and other Microsoft technologies in e-book formats. Reference, guide, and step-by-step information are all available. All the e-books are free. New books will be posted as they become available.

Click here and start downloading some great ebooks as PDFs!

DevExpress - ASPxGridView - Confirm Delete on Client

Here is a snippet of code to confirm delete on the client using DevExpress ASPxGridView.

Example Message - Command Button in Grid: 

 

Inside of the HTMLRowCreated Add the following:  The code below will pull values from the ASPxGridView and add these to message inside of the button's ClientSideScriptEvent handler.

//Get Values from Grid
ASPxGridView grid = (ASPxGridView)sender;
object[] rowValues = (object[])grid.GetRowValues(e.VisibleIndex, 
   new string[] { "StockSymbol", "ExpirationDate", "CompanyName", "OptionType", "Strike" });
string StockSymbol = Convert.ToString(rowValues[0]);
DateTime ExpirationDate = Convert.ToDateTime(rowValues[1]);
string CompName = Convert.ToString(rowValues[2]);
string OptionType = Convert.ToString(rowValues[3]);
string Strike = Convert.ToString(rowValues[4]);

//.... other code....

//Set the button message        
BtnWatchlist.ImageUrl = "~/Controls/Images/icon_minus.png";
BtnWatchlist.ToolTip = "Remove From Watchlist";

//Set JavaScript
string JavaScript = "function(s, e){ e.processOnServer = confirm('$$MSG'); }";

//Set client message
string WatchlistMsg = @"Are you sure you want to remove? \n\n"
+ "Option: " + StockSymbol
+ " - " + OptionType
+ " - " + ExpirationDate.ToShortDateString()
+ " - Strike: " + Strike;

JavaScript = JavaScript.Replace("$$MSG", WatchlistMsg);
//Add event
BtnWatchlist.ClientSideEvents.Click = JavaScript;