Hello
I have a little problem with a GridButtonColumn in a RadGrid. First of all, the grid is completeley created by code. I need to manage editing, insert and delete operations. Everythimg works good, except that I would like to have a confirm message before the delete command occurs.
Here follows the code:
RadGrid grid = new RadGrid();
grid.ID = "instGrid";
grid.DataSourceID = "sqlInst";
grid.PageSize = 15;
grid.AllowPaging = true;
grid.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
grid.AutoGenerateColumns = false;
grid.AllowAutomaticUpdates = false;
grid.AllowAutomaticInserts = false;
grid.AllowAutomaticDeletes = false;
grid.ItemCommand += new GridCommandEventHandler(instGrid_ItemCommand);
//2.1 Add Customers table
grid.MasterTableView.DataKeyNames = new string[] { "id_badmstorage", "value" };
grid.MasterTableView.EditMode = GridEditMode.EditForms;
grid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top;
GridBoundColumn boundColumn = new GridBoundColumn();
boundColumn.DataField = "id_badmstorage";
boundColumn.HeaderText = "ID";
boundColumn.ReadOnly = true;
grid.MasterTableView.Columns.Add(boundColumn);
//2.2 SET SQL DATA SOURCE...
sqlInst.SelectCommand = "SELECT * FROM DataTable WHERE variableID=" + bv.ID + " AND siteID=438 AND dataStatus=0";
//3. Add grid columns...
GridTemplateColumn tempC = null;//new GridTemplateColumn();
tempC = new GridTemplateColumn();
tempC.DataField = "value";
tempC.HeaderText = bv.Name;
tempC.ItemTemplate = new MyTemplate("value", bv.CvIndex, true);
tempC.EditItemTemplate = new CustomEditTemplate("value", true, bv.Unit, bv.CvIndex);
grid.MasterTableView.Columns.Add(tempC);
//4. Edit commands
GridEditCommandColumn eCol = new GridEditCommandColumn();
grid.MasterTableView.Columns.Add(eCol);
eCol.UniqueName = "EditCommandColumn";
//5. delete command
GridButtonColumn delCol = new GridButtonColumn();
grid.MasterTableView.Columns.Add(delCol);
delCol.HeaderText = "Delete";
delCol.UniqueName = "Delete";
delCol.CommandName = "Delete";
delCol.ConfirmDialogType = GridConfirmDialogType.Classic;
delCol.ConfirmTitle = "Delete";
delCol.ButtonType = GridButtonColumnType.ImageButton;
// Add the grid to the placeholder
this.PlaceHolder1.Controls.Add(grid);
//AJAX SETTINGS...
AjaxSetting ajax = new AjaxSetting(grid.ID);
AjaxUpdatedControl up=new AjaxUpdatedControl();
up.ControlID=grid.ID;
ajax.UpdatedControls.Add(up);
up = new AjaxUpdatedControl();
ajax.UpdatedControls.Add(up);
RadAjaxManager1.AjaxSettings.Add(ajax);
The grid is created in the Page_Init event
A preview of the page can be found at this link (select INST_MODEL from the list)
If you try to delete a record, no confirm window appears (deletion is disabled for now)
Thanks
Diego