I've seen other posts where people are having similar issues. I tried their suggestions and still no good. I cannot get this grid to fire the update command. I'm programmatically creating the grid and using a template edit form...
Grid setup:
| private void SetupStoreGridView() |
| { |
| // create columns |
| GridEditCommandColumn storeEditCol = new GridEditCommandColumn(); |
| GridBoundColumn storeNumberCol = new GridBoundColumn(); |
| GridBoundColumn storeNameCol = new GridBoundColumn(); |
| GridBoundColumn storePhoneCol = new GridBoundColumn(); |
| GridBoundColumn storeAddressCol = new GridBoundColumn(); |
| GridBoundColumn storeCityCol = new GridBoundColumn(); |
| GridBoundColumn storeStateCol = new GridBoundColumn(); |
| GridBoundColumn storeZipCol = new GridBoundColumn(); |
| GridBoundColumn storeDesignNameCol = new GridBoundColumn(); |
| GridBoundColumn storeChocolixirCol = new GridBoundColumn(); |
| // main grid properties |
| m_StoreGridViewRad = new RadGrid(); |
| m_StoreGridViewRad.ID = "StoreGridViewRad"; |
| m_StoreGridViewRad.GridLines = GridLines.Vertical; |
| m_StoreGridViewRad.AllowMultiRowSelection = false; |
| m_StoreGridViewRad.AutoGenerateColumns = false; |
| m_StoreGridViewRad.AllowSorting = true; |
| m_StoreGridViewRad.Skin = "WebBlue"; |
| m_StoreGridViewRad.Width = Unit.Percentage(95); |
| m_StoreGridViewRad.UpdateCommand += new GridCommandEventHandler(m_StoreGridViewRad_UpdateCommand); |
| m_StoreGridViewRad.MasterTableView.AllowAutomaticUpdates = true; |
| m_StoreGridViewRad.MasterTableView.EditFormSettings.EditFormType = GridEditFormType.Template; |
| m_StoreGridViewRad.MasterTableView.EditFormSettings.FormTemplate = new EditStoreTemplate(); |
| m_StoreGridViewRad.NeedDataSource += new GridNeedDataSourceEventHandler(StoreGridViewRad_NeedDataSource); |
| m_StoreGridViewRad.AllowFilteringByColumn = true; |
| m_StoreGridViewRad.MasterTableView.DataKeyNames = new string[] { StoreAccess.StoreNumber }; |
| m_StoreGridViewRad.MasterTableView.EnableNoRecordsTemplate = true; |
| // add columns to grid |
| m_StoreGridViewRad.MasterTableView.Columns.Add(storeEditCol); |
| m_StoreGridViewRad.MasterTableView.Columns.Add(storeNumberCol); |
| m_StoreGridViewRad.MasterTableView.Columns.Add(storeNameCol); |
| m_StoreGridViewRad.MasterTableView.Columns.Add(storePhoneCol); |
| m_StoreGridViewRad.MasterTableView.Columns.Add(storeAddressCol); |
| m_StoreGridViewRad.MasterTableView.Columns.Add(storeCityCol); |
| m_StoreGridViewRad.MasterTableView.Columns.Add(storeStateCol); |
| m_StoreGridViewRad.MasterTableView.Columns.Add(storeZipCol); |
| m_StoreGridViewRad.MasterTableView.Columns.Add(storeDesignNameCol); |
| m_StoreGridViewRad.MasterTableView.Columns.Add(storeChocolixirCol); |
| SetupGridViewColumn(storeNumberCol, StoreAccess.StoreNumber, "Store Number"); |
| SetupGridViewColumn(storeNameCol, StoreAccess.StoreName, StoreAccess.StoreName); |
| SetupGridViewColumn(storePhoneCol, StoreAccess.Phone, StoreAccess.Phone); |
| SetupGridViewColumn(storeAddressCol, StoreAccess.Address, StoreAccess.Address); |
| SetupGridViewColumn(storeCityCol, StoreAccess.City, StoreAccess.City); |
| SetupGridViewColumn(storeStateCol, StoreAccess.State, StoreAccess.State); |
| SetupGridViewColumn(storeZipCol, StoreAccess.Zip, StoreAccess.Zip); |
| SetupGridViewColumn(storeDesignNameCol, StoreAccess.DesignName, "Design Name"); |
| SetupGridViewColumn(storeChocolixirCol, StoreAccess.Chocolixir, StoreAccess.Chocolixir); |
| GridViewPlaceHolder.Controls.Add(m_StoreGridViewRad); |
| } |
| void m_StoreGridViewRad_UpdateCommand(object source, GridCommandEventArgs e) |
| { |
| GridEditableItem ei = ((GridEditableItem)(e.Item)); |
| Hashtable t1 = new Hashtable(); |
| ei.ExtractValues(t1); |
| string s = t1[StoreAccess.StoreName].ToString(); |
| } |
| protected void StoreGridViewRad_NeedDataSource(object source, GridNeedDataSourceEventArgs e) |
| { |
| GetStoresToBind(); |
| } |
| void SetupGridViewColumn(GridColumn col, string uniqueName, string heading) |
| { |
| col.HeaderText = heading; |
| col.UniqueName = uniqueName; |
| col.ItemStyle.HorizontalAlign = HorizontalAlign.Left; |
| if (col is GridBoundColumn) |
| { |
| GridBoundColumn bCol = col as GridBoundColumn; |
| bCol.DataField = uniqueName; |
| } |
| else if (col is GridButtonColumn) |
| { |
| GridButtonColumn buttonCol = col as GridButtonColumn; |
| buttonCol.CommandName = uniqueName; |
| buttonCol.Text = uniqueName; |
| } |
| } |
template:
| public class EditStoreTemplate : IBindableTemplate |
| { |
| public EditStoreTemplate() |
| { |
| } |
| #region ITemplate Members |
| public void InstantiateIn(Control container) |
| { |
| GridEditFormItem item = ((GridEditFormItem)(container.NamingContainer)); |
| if (item != null) |
| { |
| int index = ((GridDataItem)item.ParentItem).ItemIndex; |
| if (item.DataItem != null) |
| { |
| RadTextBox storeNumberTB = new RadTextBox() |
| { |
| ID = "txtStorNumber", |
| Text = DataBinder.Eval(item.DataItem, StoreAccess.StoreNumber, "{0}"), |
| Skin = "WebBlue", |
| CausesValidation = false |
| }; |
| container.Controls.Add(storeNumberTB); |
| RadTextBox storeNameTB = new RadTextBox() |
| { |
| ID = "txtStoreName", |
| Text = DataBinder.Eval(item.DataItem, StoreAccess.StoreName, "{0}"), |
| Skin = "WebBlue", |
| CausesValidation = false |
| }; |
| container.Controls.Add(storeNameTB); |
| RadTextBox addrTB = new RadTextBox() |
| { |
| ID = "txtAddr", |
| Text = DataBinder.Eval(item.DataItem, StoreAccess.Address, "{0}"), |
| Skin = "WebBlue", |
| CausesValidation = false |
| }; |
| container.Controls.Add(addrTB); |
| RadTextBox cityTB = new RadTextBox() |
| { |
| ID = "txtCity", |
| Text = DataBinder.Eval(item.DataItem, StoreAccess.City, "{0}"), |
| Skin = "WebBlue", |
| CausesValidation = false |
| }; |
| container.Controls.Add(cityTB); |
| RadTextBox stateTB = new RadTextBox() |
| { |
| ID = "txtState", |
| Text = DataBinder.Eval(item.DataItem, StoreAccess.State, "{0}"), |
| Skin = "WebBlue", |
| CausesValidation = false |
| }; |
| container.Controls.Add(stateTB); |
| RadTextBox zipTB = new RadTextBox() |
| { |
| ID = "txtZip", |
| Text = DataBinder.Eval(item.DataItem, StoreAccess.Zip, "{0}"), |
| Skin = "WebBlue", |
| CausesValidation = false |
| }; |
| container.Controls.Add(zipTB); |
| RadMaskedTextBox phoneTB = new RadMaskedTextBox() |
| { |
| ID = "txtPhone", |
| Text = DataBinder.Eval(item.DataItem, StoreAccess.Phone, "{0}"), |
| Skin = "WebBlue", |
| CausesValidation = false |
| }; |
| container.Controls.Add(phoneTB); |
| RadTextBox notesTB = new RadTextBox() |
| { |
| ID = "txtNotes", |
| Text = DataBinder.Eval(item.DataItem, StoreAccess.Notes, "{0}"), |
| Skin = "WebBlue", |
| CausesValidation = false |
| }; |
| container.Controls.Add(notesTB); |
| RadComboBox designNameCombo = new RadComboBox() |
| { |
| ID = "cboDesignName", |
| DataSource = DesignAccess.GetDesign(), |
| DataTextField = DesignAccess.DesignName, |
| DataValueField = DesignAccess.DesignNumber, |
| SelectedValue = DataBinder.Eval(item.DataItem, StoreAccess.DesignNumber, "{0}"), |
| Skin = "WebBlue", |
| CausesValidation = false |
| }; |
| container.Controls.Add(designNameCombo); |
| RadTextBox regionTb = new RadTextBox() |
| { |
| ID= "txtRegion", |
| Text = DataBinder.Eval(item.DataItem,StoreAccess.Reg,"{0}"), |
| Skin = "WebBlue", |
| CausesValidation = false |
| }; |
| container.Controls.Add(regionTb); |
| RadTextBox typeTB = new RadTextBox() |
| { |
| ID = "txtType", |
| Text= DataBinder.Eval(item.DataItem,StoreAccess.Type,"{0}"), |
| Skin = "WebBlue", |
| CausesValidation = false |
| }; |
| container.Controls.Add(typeTB); |
| CheckBox chocolixirCB = new CheckBox() |
| { |
| ID = "chkChocolixir", |
| Checked = bool.Parse(DataBinder.Eval(item.DataItem, StoreAccess.Chocolixir, "{0}")), |
| Text = StoreAccess.Chocolixir, |
| CausesValidation = false |
| }; |
| container.Controls.Add(chocolixirCB); |
| CheckBox gCB = new CheckBox() |
| { |
| ID = "chkG", |
| Checked = bool.Parse(DataBinder.Eval(item.DataItem, StoreAccess.G, "{0}")), |
| Text = "G", |
| CausesValidation = false |
| }; |
| container.Controls.Add(gCB); |
| Button updateButton = new Button() |
| { |
| ID = "updateButton", |
| Text = "Update", |
| CommandName = "Update", |
| CausesValidation = false |
| }; |
| container.Controls.Add(updateButton); |
| Button cancelButton = new Button() |
| { |
| ID = "cancelButton", |
| Text = "Cancel", |
| CausesValidation = false |
| }; |
| cancelButton.Click += new EventHandler(cancelButton_Click); |
| container.Controls.Add(cancelButton); |
| } |
| } |
| } |
| void cancelButton_Click(object sender, EventArgs e) |
| { |
| } |
| #endregion |
| #region IBindableTemplate Members |
| public System.Collections.Specialized.IOrderedDictionary ExtractValues(Control container) |
| { |
| OrderedDictionary od = new OrderedDictionary(); |
| od.Add(StoreAccess.StoreName,(container.FindControl("txtStoreName") as RadTextBox).Text); |
| return od; |
| } |
| #endregion |
| } |
maybe i'm doing something wrong... but i'm pretty sure i followed the demo page closely. any help would be wonderful.
Thanks,
Dave