I have a RadGrid with NeedDataSource binding. It also has an EditTemplate. The following code works well for saving the users updates except that the EditTemplate doesn't close. How do I close the EditTemplate?
protected void ModelGrid_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.UpdateEditedCommandName)
{
if (e.Item is GridEditFormItem)
{
GridEditFormItem item = (GridEditFormItem)e.Item;
string id = item.GetDataKeyValue("ModelId").ToString();
if (!String.IsNullOrEmpty(id))
{
Model m = new Model();
try
{
m.ModelId = id;
m.ManufacturerId = SelctedManufacturerId;
m.ModelNumber = ((TextBox)item.FindControl("txtEditModelNumber")).Text;
m.Description = ((TextBox)item.FindControl("txtEditDescription")).Text;
m.ProductLineId = ((RadComboBox)item.FindControl("ddlProductLine")).SelectedValue;
m.AssetTypeId = ((RadComboBox)item.FindControl("ddlAssetType")).SelectedValue;
m.DefAssetPosition = int.Parse(((DropDownList)item.FindControl("ddlDefAssetPos")).SelectedValue);
m.UseRackUnits = ((CheckBox)item.FindControl("chkUseRack")).Checked;
m.Height = (Double)((RadNumericTextBox)item.FindControl("numEditHeight")).Value;
m.Width = (Double)((RadNumericTextBox)item.FindControl("numEditWidth")).Value;
m.Depth = (Double)((RadNumericTextBox)item.FindControl("numEditDepth")).Value;
AssetVueBLL.UpdateModel(m, MySession.Current.UserId);
ModelGrid.Rebind();
}
catch (Exception ex)
{
ModelGrid.Controls.Add(new LiteralControl("<strong>Unable to save Model</strong> - " + ex.Message));
e.Canceled = true;
}
}
}
}
}
protected void ModelGrid_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.UpdateEditedCommandName)
{
if (e.Item is GridEditFormItem)
{
GridEditFormItem item = (GridEditFormItem)e.Item;
string id = item.GetDataKeyValue("ModelId").ToString();
if (!String.IsNullOrEmpty(id))
{
Model m = new Model();
try
{
m.ModelId = id;
m.ManufacturerId = SelctedManufacturerId;
m.ModelNumber = ((TextBox)item.FindControl("txtEditModelNumber")).Text;
m.Description = ((TextBox)item.FindControl("txtEditDescription")).Text;
m.ProductLineId = ((RadComboBox)item.FindControl("ddlProductLine")).SelectedValue;
m.AssetTypeId = ((RadComboBox)item.FindControl("ddlAssetType")).SelectedValue;
m.DefAssetPosition = int.Parse(((DropDownList)item.FindControl("ddlDefAssetPos")).SelectedValue);
m.UseRackUnits = ((CheckBox)item.FindControl("chkUseRack")).Checked;
m.Height = (Double)((RadNumericTextBox)item.FindControl("numEditHeight")).Value;
m.Width = (Double)((RadNumericTextBox)item.FindControl("numEditWidth")).Value;
m.Depth = (Double)((RadNumericTextBox)item.FindControl("numEditDepth")).Value;
AssetVueBLL.UpdateModel(m, MySession.Current.UserId);
ModelGrid.Rebind();
}
catch (Exception ex)
{
ModelGrid.Controls.Add(new LiteralControl("<strong>Unable to save Model</strong> - " + ex.Message));
e.Canceled = true;
}
}
}
}
}