I have used Batch Edit in Radgrid , when i click on cell in radgrid textbox is appearing instead of radcombobox. value every thing is binding properly but dropdown is not appearing, if i click on cell. I am creating dynamic grid. Code given below.
RadGrid grd = new RadGrid();
//grd.PreRender += new EventHandler(grd_PreRender);
grd.NeedDataSource += new GridNeedDataSourceEventHandler(grd_NeedDataSource);
grd.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
//OnetimeRevision
if (_isPartLevelEditable)
{
if (UserManager.IsAdminOrPM(UserRepository.CurrentUser))
//(SessionManager.LoginUser.Role == Constants.ADMINROLE || SessionManager.LoginUser.Role == Constants.PROGRAMMANAGERROLE)
{
if (_ecr != null)
{
if (_ecr.EcrState == Constants.ECRSTATUSINITIATE || _ecr.EcrState == Constants.ECRSTATUSECOINITIATED || _ecr.EcrState == Constants.ECRSTATUSKICKEDOFF || _ecr.EcrState == Constants.ECRSTATUSIMPLEMENTED || _ecr.EcrState == Constants.ECRSTATUSCOMPLETE)
{
grd.UpdateCommand += new GridCommandEventHandler(grdCurrentAffectedPart_UpdateCommand);
}
if (_ecr != null && _ecr.EcrState == Constants.ECRSTATUSINITIATE)
{
grd.DeleteCommand += new GridCommandEventHandler(grd_DeleteCommand);
}
}
else
{
grd.UpdateCommand += new GridCommandEventHandler(grdCurrentAffectedPart_UpdateCommand);
grd.DeleteCommand += new GridCommandEventHandler(grd_DeleteCommand);
}
}
grd.ItemDataBound += new GridItemEventHandler(grd_ItemDataBound);
grd.MasterTableView.EditMode = GridEditMode.Batch;
grd.MasterTableView.AllowAutomaticInserts = true;
grd.MasterTableView.AllowAutomaticUpdates = true;
grd.MasterTableView.AllowAutomaticDeletes = true;
grd.MasterTableView.BatchEditingSettings.EditType = GridBatchEditingType.Cell;
//grd.MasterTableView.BatchEditingSettings.EditType = Cell;
// grd.MasterTableView.EditFormSettings.PopUpSettings.Modal = true;
//popup borders and color
// grd.MasterTableView.EditFormSettings.FormStyle.BorderWidth = Unit.Pixel(5);
//string hexvalue="#7da5e0";
// grd.MasterTableView.EditFormSettings.FormStyle.BorderColor = System.Drawing.ColorTranslator.FromHtml(hexvalue);
//---
//if (_ecr != null)
//{
// grd.MasterTableView.EditFormSettings.CaptionFormatString = UIMessages.FinancalLinfoEcNumber + Constants.SPACE + _ecr.EcrNumber;
//}
grd.ClientSettings.Selecting.AllowRowSelect = true;
grd.ClientSettings.Scrolling.AllowScroll = true;
//grd.ClientSettings.ClientEvents.OnPopUpShowing = "OnPopUpShowing";
//set attributes for pre/ecr/release part level collumn ordinal as comma sepearate
}
grd.ItemCreated += new GridItemEventHandler(grd_ItemCreated);
grd.MasterTableView.CommandItemSettings.ShowRefreshButton = false;
grd.Attributes.Add(Constants.ENABLELINQEXPRESSIONS, Constants.FALSE);
grd.ColumnCreated += new GridColumnCreatedEventHandler(grdCurrentAffectedPart_ColumnCreated);
grd.ID = dsEcrParts.Tables[i].TableName;
//grd.MasterTableView.EditFormSettings.InsertCaption = _ecr.EcrNumber;
grd.Attributes.Add(Constants.INDEXTEXT, i.ToString(CultureInfo.InvariantCulture));
grd.MasterTableView.DataKeyNames = new string[] { Constants.ECRPARTID, Constants.ECRID, Constants.PARTPRODUCTIONSOURCEID, "ChildParts" };
grd.Width = 1400;
grd.Height = Unit.Percentage(100);
grd.MasterTableView.Width = Unit.Percentage(100);
grd.MasterTableView.Height = Unit.Percentage(100);
grd.ClientSettings.Scrolling.AllowScroll = true;
// grd.ClientSettings.Scrolling.UseStaticHeaders = true;
int freezeColumnCount = 7;
int.TryParse(ConfigurationManager.AppSettings[Constants.ECRFREEZECOLUMNSCOUNT], out freezeColumnCount);
grd.ClientSettings.Scrolling.FrozenColumnsCount = freezeColumnCount;
SetEditableColumns(dsEcrParts.Tables[i], grd, _ecr);
if (UserManager.IsAdminOrPM(UserRepository.CurrentUser))
//(SessionManager.LoginUser.Role == Constants.ADMINROLE || SessionManager.LoginUser.Role == Constants.PROGRAMMANAGERROLE)
{
if (_ecr != null)
{
//Production Y && Main ECR and States = I or O or K or M then add edit column else no edit
//production N && Main ECR && states = I or O then add edit else no edit
//SUB ECR && PRODUCTION = Y AND STATES = I OR O OR M THEN ADD EDIT COLUMN ELSE NO EDIT COLUMN
//shyam (IsProduction in ECR)
//OnetimeRevision
if (
(!_ecr.SubEcr && ((_ecr.EcrState == Constants.ECRSTATUSINITIATE || _ecr.EcrState == Constants.ECRSTATUSECOINITIATED)
|| (_ecr.IsProduction && (_ecr.EcrState == Constants.ECRSTATUSKICKEDOFF || _ecr.EcrState == Constants.ECRSTATUSIMPLEMENTED))))
|| (_ecr.SubEcr && _ecr.IsProduction && (_ecr.EcrState == Constants.ECRSTATUSECOINITIATED || _ecr.EcrState == Constants.ECRSTATUSKICKEDOFF || _ecr.EcrState == Constants.ECRSTATUSIMPLEMENTED))////If not sub ecr then editable at initate stage as well
|| (!_ecr.SubEcr && _ecr.RevisionInProgress && ((!_ecr.IsProduction && _ecr.EcrState == Constants.ECRSTATUSIMPLEMENTED) || (_ecr.EcrState == Constants.ECRSTATUSCOMPLETE)))
) //If sub ecr then not editable at initate stage or evaluate stage
{
AddEditColumn(grd);
}
if (_ecr != null && _ecr.EcrState == Constants.ECRSTATUSINITIATE)
{
AddDeleteColumn(grd);
}
}
else
{
AddEditColumn(grd);
AddDeleteColumn(grd);
}
}
if (i == 0)
{
AddGridCollectionTitle(Constants.LBLAFFECTEDPARTS, UIMessages.AffectedParts);
}
else if (i == 1)
{
AddGridCollectionTitle(Constants.LBLPARENTPARTS, UIMessages.ParentParts);
}
PlaceHolder1.Controls.Add(grd);
PlaceHolder1.Controls.Add(new LiteralControl(Constants.BREAKTAG));
grd.Rebind();
protected void grd_ItemDataBound(object sender, GridItemEventArgs e)
{
RadGrid senderGrid = (RadGrid)sender;
List<string> editabeColumns = (List<string>)_columnOrdinal[sender];
if (e.Item is GridDataItem)
{
GridDataItem dataItem = e.Item as GridDataItem;
if (e.Item.OwnerTableView.Columns.FindByUniqueNameSafe(Constants.DELETECOLUMN) != null)
{
ImageButton img = dataItem[Constants.DELETECOLUMN].Controls[0] as ImageButton;
if (dataItem[Constants.DELETECOLUMN].Controls.Count > 0)
{
//ECR ECRNumber = null;
//int ecrId = 0;
//if (ECRId.Length > 0 && ECRId != Constants.ZeroNumber)
//{
// ecrId = Convert.ToInt32(ECRId);
// using (var ecrManager = new ECRECOManager())
// {
// ECRNumber = ecrManager.FindECR(Convert.ToDecimal(ECRId));
// }
// string deleteMessage = UIMessages.Delete + " - " + UIMessages.FinancalLinfoEcNumber + " " + ECRNumber.EcrNumber;
// img.Attributes.Add(Constants.ONCLICK, string.Format(CultureInfo.CurrentUICulture, Constants.POPUPCONFIRM, senderGrid.ClientID, UIMessages.RADGRIDCONFIRMDELETEECRPARTSCRIPT, deleteMessage));
//}
//else
img.Attributes.Add(Constants.ONCLICK, string.Format(CultureInfo.CurrentUICulture, Constants.POPUPCONFIRM, senderGrid.ClientID, UIMessages.RADGRIDCONFIRMDELETEECRPARTSCRIPT, UIMessages.Delete));
//"if(!$find('" + senderGrid.ClientID + "').confirm('" + UIMessages.RADGRIDCONFIRMDELETEECRPARTSCRIPT + "', event, 'Delete'))return false;");
//dataItem[Constants.DELETECOLUMN].Attributes.Add(UIMessages.ONCLICK, string.Format(UIMessages.RADGRIDCONFIRMDELETEECRPARTSCRIPT, senderGrid.ClientID));
img.ToolTip = UIMessages.Delete;
if (dataItem["IsDeletable"].Text.Trim() == "0")
{
dataItem[Constants.DELETECOLUMN].Text = string.Empty;
}
}
if (senderGrid.Attributes[Constants.INDEXTEXT].Equals(Constants.ZeroNumber))
if ((dataItem.DataItem as DataRowView).Row.Table.Rows.Count == 1)
img.Visible = false;
}
if (e.Item.OwnerTableView.Columns.FindByUniqueNameSafe(Constants.EDITCOLUMN) != null)
{
if (dataItem[Constants.EDITCOLUMN].Controls.Count > 0)
{
ImageButton editBtn = (ImageButton)dataItem[Constants.EDITCOLUMN].Controls[0];
//editBtn.ToolTip = UIMessages.Edit;
editBtn.Visible = false;
}
}
}
if (e.Item is GridHeaderItem)
{
try
{
GridHeaderItem dataItem = e.Item as GridHeaderItem;
/* dataItem[Constants.PREECRPARTNUMBER].Style.Add("border-left", "2px solid #3663bd");
dataItem[Constants.ECRPARTNUMBER].Style.Add("border-left", "2px solid #3663bd");
dataItem[Constants.RELEASEDPARTNUMBER].Style.Add("border-left", "2px solid #3663bd");*/
dataItem.Style.Add("border-left", "2px solid #3663bd");
}
catch
{
}
}
GridEditableItem editedItem = e.Item as GridEditableItem;
//if (e.Item.IsInEditMode)
//{
// GridEditFormItem editform = (GridEditFormItem)e.Item;
// if (_ecr != null)
// {
// ((System.Web.UI.WebControls.TableCell)(editform.Controls[1].Controls[0].Controls[1].Controls[0].Controls[0].Controls[0])).Text =
// (_ecr.EcrState == Constants.ECRSTATUSINITIATE) ? "<b>" + UIMessages.ECREditHeader + "</b>" : "<b>" + UIMessages.ECOEditHeader + "</b>";
// }
// else
// {
// ((System.Web.UI.WebControls.TableCell)(editform.Controls[1].Controls[0].Controls[1].Controls[0].Controls[0].Controls[0])).Text =
// "<b>" + UIMessages.ECREditHeader + "</b><b>" + UIMessages.ECOEditHeader + "</b>";
// }
// // editform.EditFormCell.
//}
if (editedItem != null && e.Item.IsInEditMode)
{
//Find the row being edited in the session stored DataSet
decimal partID = Convert.ToDecimal(editedItem.GetDataKeyValue(Constants.PARTPRODUCTIONSOURCEID));
DataRow editRow = ECRPartsSession.Tables[senderGrid.ID].Select(string.Format(CultureInfo.InvariantCulture, Constants.SEARCHPARTFILTER, partID)).First();
//editedItem[Constants.AFFECTEDPART].Enabled = false;
//Fill editable TextBoxes
foreach (string columnName in editabeColumns)
{
//Fill ECRType DropDown
if (columnName.Equals(Constants.ECRTYPE))
{
string ecrType = editRow[Constants.ECRTYPE].ToString();
RadComboBox combo = (RadComboBox)editedItem.FindControl(senderGrid.ID + Constants.ECRTYPE);
combo.Focus();
if (combo != null)
{
FillAccessDropDown(combo, ecrType);
if (ecrType == Constants.ECRPARTLEVELTYPEPREECR)
{
//combo.SelectedIndex = combo.FindItemIndexByValue(Constants.ECRTYPEADD);
combo.SelectedValue = Constants.ECRTYPEADD;
}
else
{
//combo.SelectedIndex= combo.FindItemIndexByText("O");
combo.SelectedValue = ecrType == "O" ? "D" : ecrType;
}
}
}
//Fill ToolSource location DropDowns
else if (_toolSourcelocationColumns.Contains(columnName) && !Production)
{
if ((editedItem.OwnerTableView.AutoGeneratedColumns.Any(gc => gc.UniqueName == columnName)))
{
if (editedItem[columnName] != null) //&& editedItem[locationColumn].Controls.Count <= 1)
{
RadComboBox comboLocTool = (RadComboBox)editedItem.FindControl(senderGrid.ID + columnName);
if (comboLocTool != null)
{
FillLocation(comboLocTool, _toolSource, editRow[columnName]);
RadComboBoxItem foundItem = null;
string valueColumn = columnName.Replace(Constants.NAME, string.Empty);
foundItem = comboLocTool.FindItemByValue(Convert.ToString(((editedItem.DataItem as DataRowView))[valueColumn]));
if (comboLocTool.Items.Contains(foundItem))
{
comboLocTool.SelectedValue = foundItem.Value;// ((editedItem.DataItem as DataRowView))[valueColumn].ToString();
}
}
}
}
}
//Fill FixtureSource location DropDowns
else if (_fixtureSourcelocationColumns.Contains(columnName) && !Production)
{
if ((editedItem.OwnerTableView.AutoGeneratedColumns.Any(gc => gc.UniqueName == columnName)))
{
if (editedItem[columnName] != null) //&& editedItem[locationColumn].Controls.Count <= 1)
{
RadComboBox comboLocTool = (RadComboBox)editedItem.FindControl(senderGrid.ID + columnName);
if (comboLocTool != null)
{
FillLocation(comboLocTool, _fixtureSource, editRow[columnName]);
RadComboBoxItem foundItem = null;
string valueColumn = columnName.Replace(Constants.NAME, string.Empty);
foundItem = comboLocTool.FindItemByValue(Convert.ToString(((editedItem.DataItem as DataRowView))[valueColumn]));
if (comboLocTool.Items.Contains(foundItem))
{
comboLocTool.SelectedValue = foundItem.Value;// ((editedItem.DataItem as DataRowView))[valueColumn].ToString();
}
}
}
}
}
//Fill ProductionSource location DropDowns
else if (_productionSourcelocationColumns.Contains(columnName))
{
if ((editedItem.OwnerTableView.AutoGeneratedColumns.Any(gc => gc.UniqueName == columnName)))
{
if (editedItem[columnName] != null) //&& editedItem[locationColumn].Controls.Count <= 1)
{
RadComboBox comboLocProd = (RadComboBox)editedItem.FindControl(senderGrid.ID + columnName);
if (comboLocProd != null)
{
FillLocation(comboLocProd, _productionSource, editRow[columnName]);
RadComboBoxItem foundItem = null;
string valueColumn = columnName.Replace(Constants.NAME, string.Empty);
foundItem = comboLocProd.FindItemByValue(Convert.ToString(((editedItem.DataItem as DataRowView))[valueColumn]));
if (comboLocProd.Items.Contains(foundItem))
{
comboLocProd.SelectedValue = foundItem.Value;// ((editedItem.DataItem as DataRowView))[Constants.ECRPRODUCTIONSOURCE].ToString();
}
}
}
}
}
//Fill Date fields
else if (_dateFields.Contains(columnName) && Production)
{
if ((editedItem.OwnerTableView.AutoGeneratedColumns.Any(gc => gc.UniqueName == columnName)))
{
if (editedItem[columnName] != null) //&& editedItem[locationColumn].Controls.Count <= 1)
{
RadDatePicker rdpDate = editedItem[columnName].Controls[0] as RadDatePicker;
if (rdpDate != null)
{
if (!string.IsNullOrEmpty(Convert.ToString(editRow[columnName])))
rdpDate.SelectedDate = Convert.ToDateTime(Convert.ToString(editRow[columnName]));
if (columnName == Constants.BASELINEMRDTOPLANTDATE || columnName == Constants.BASELINEPPAPDATE)
{
rdpDate.ClientEvents.OnDateSelected = "GMS.Masters.ECR.Part.ecoBaselineDateSelected";
}
if (columnName == Constants.PLANMRDTOPLANTDATE || columnName == Constants.PLANPPAPDATE)
{
if (rdpDate.SelectedDate == null)
rdpDate.Attributes.Add("HasValue", "false");
else
rdpDate.Attributes.Add("HasValue", "true");
}
}
}
}
}
else
{
if ((editedItem.OwnerTableView.AutoGeneratedColumns.Any(gc => gc.UniqueName == columnName)))
{
if (editedItem[columnName] != null) //&& editedItem[columnName].Controls.Count <= 1)
{
RadTextBox txtBox = (RadTextBox)editedItem.FindControl(senderGrid.ID + columnName);
if (txtBox != null)
{
txtBox.Text = Convert.ToString(editRow[columnName]);
//txtBox.ClientEvents.OnValueChanged = "debugger;OnTextValueChanged();";
// txtBox.Attributes.Add("onchange", "debugger;return GMS.ECR.ManageEcrEco.OnTextValueChanged();");
}
}
}
}
}
}
}
RadGrid grd = new RadGrid();
//grd.PreRender += new EventHandler(grd_PreRender);
grd.NeedDataSource += new GridNeedDataSourceEventHandler(grd_NeedDataSource);
grd.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
//OnetimeRevision
if (_isPartLevelEditable)
{
if (UserManager.IsAdminOrPM(UserRepository.CurrentUser))
//(SessionManager.LoginUser.Role == Constants.ADMINROLE || SessionManager.LoginUser.Role == Constants.PROGRAMMANAGERROLE)
{
if (_ecr != null)
{
if (_ecr.EcrState == Constants.ECRSTATUSINITIATE || _ecr.EcrState == Constants.ECRSTATUSECOINITIATED || _ecr.EcrState == Constants.ECRSTATUSKICKEDOFF || _ecr.EcrState == Constants.ECRSTATUSIMPLEMENTED || _ecr.EcrState == Constants.ECRSTATUSCOMPLETE)
{
grd.UpdateCommand += new GridCommandEventHandler(grdCurrentAffectedPart_UpdateCommand);
}
if (_ecr != null && _ecr.EcrState == Constants.ECRSTATUSINITIATE)
{
grd.DeleteCommand += new GridCommandEventHandler(grd_DeleteCommand);
}
}
else
{
grd.UpdateCommand += new GridCommandEventHandler(grdCurrentAffectedPart_UpdateCommand);
grd.DeleteCommand += new GridCommandEventHandler(grd_DeleteCommand);
}
}
grd.ItemDataBound += new GridItemEventHandler(grd_ItemDataBound);
grd.MasterTableView.EditMode = GridEditMode.Batch;
grd.MasterTableView.AllowAutomaticInserts = true;
grd.MasterTableView.AllowAutomaticUpdates = true;
grd.MasterTableView.AllowAutomaticDeletes = true;
grd.MasterTableView.BatchEditingSettings.EditType = GridBatchEditingType.Cell;
//grd.MasterTableView.BatchEditingSettings.EditType = Cell;
// grd.MasterTableView.EditFormSettings.PopUpSettings.Modal = true;
//popup borders and color
// grd.MasterTableView.EditFormSettings.FormStyle.BorderWidth = Unit.Pixel(5);
//string hexvalue="#7da5e0";
// grd.MasterTableView.EditFormSettings.FormStyle.BorderColor = System.Drawing.ColorTranslator.FromHtml(hexvalue);
//---
//if (_ecr != null)
//{
// grd.MasterTableView.EditFormSettings.CaptionFormatString = UIMessages.FinancalLinfoEcNumber + Constants.SPACE + _ecr.EcrNumber;
//}
grd.ClientSettings.Selecting.AllowRowSelect = true;
grd.ClientSettings.Scrolling.AllowScroll = true;
//grd.ClientSettings.ClientEvents.OnPopUpShowing = "OnPopUpShowing";
//set attributes for pre/ecr/release part level collumn ordinal as comma sepearate
}
grd.ItemCreated += new GridItemEventHandler(grd_ItemCreated);
grd.MasterTableView.CommandItemSettings.ShowRefreshButton = false;
grd.Attributes.Add(Constants.ENABLELINQEXPRESSIONS, Constants.FALSE);
grd.ColumnCreated += new GridColumnCreatedEventHandler(grdCurrentAffectedPart_ColumnCreated);
grd.ID = dsEcrParts.Tables[i].TableName;
//grd.MasterTableView.EditFormSettings.InsertCaption = _ecr.EcrNumber;
grd.Attributes.Add(Constants.INDEXTEXT, i.ToString(CultureInfo.InvariantCulture));
grd.MasterTableView.DataKeyNames = new string[] { Constants.ECRPARTID, Constants.ECRID, Constants.PARTPRODUCTIONSOURCEID, "ChildParts" };
grd.Width = 1400;
grd.Height = Unit.Percentage(100);
grd.MasterTableView.Width = Unit.Percentage(100);
grd.MasterTableView.Height = Unit.Percentage(100);
grd.ClientSettings.Scrolling.AllowScroll = true;
// grd.ClientSettings.Scrolling.UseStaticHeaders = true;
int freezeColumnCount = 7;
int.TryParse(ConfigurationManager.AppSettings[Constants.ECRFREEZECOLUMNSCOUNT], out freezeColumnCount);
grd.ClientSettings.Scrolling.FrozenColumnsCount = freezeColumnCount;
SetEditableColumns(dsEcrParts.Tables[i], grd, _ecr);
if (UserManager.IsAdminOrPM(UserRepository.CurrentUser))
//(SessionManager.LoginUser.Role == Constants.ADMINROLE || SessionManager.LoginUser.Role == Constants.PROGRAMMANAGERROLE)
{
if (_ecr != null)
{
//Production Y && Main ECR and States = I or O or K or M then add edit column else no edit
//production N && Main ECR && states = I or O then add edit else no edit
//SUB ECR && PRODUCTION = Y AND STATES = I OR O OR M THEN ADD EDIT COLUMN ELSE NO EDIT COLUMN
//shyam (IsProduction in ECR)
//OnetimeRevision
if (
(!_ecr.SubEcr && ((_ecr.EcrState == Constants.ECRSTATUSINITIATE || _ecr.EcrState == Constants.ECRSTATUSECOINITIATED)
|| (_ecr.IsProduction && (_ecr.EcrState == Constants.ECRSTATUSKICKEDOFF || _ecr.EcrState == Constants.ECRSTATUSIMPLEMENTED))))
|| (_ecr.SubEcr && _ecr.IsProduction && (_ecr.EcrState == Constants.ECRSTATUSECOINITIATED || _ecr.EcrState == Constants.ECRSTATUSKICKEDOFF || _ecr.EcrState == Constants.ECRSTATUSIMPLEMENTED))////If not sub ecr then editable at initate stage as well
|| (!_ecr.SubEcr && _ecr.RevisionInProgress && ((!_ecr.IsProduction && _ecr.EcrState == Constants.ECRSTATUSIMPLEMENTED) || (_ecr.EcrState == Constants.ECRSTATUSCOMPLETE)))
) //If sub ecr then not editable at initate stage or evaluate stage
{
AddEditColumn(grd);
}
if (_ecr != null && _ecr.EcrState == Constants.ECRSTATUSINITIATE)
{
AddDeleteColumn(grd);
}
}
else
{
AddEditColumn(grd);
AddDeleteColumn(grd);
}
}
if (i == 0)
{
AddGridCollectionTitle(Constants.LBLAFFECTEDPARTS, UIMessages.AffectedParts);
}
else if (i == 1)
{
AddGridCollectionTitle(Constants.LBLPARENTPARTS, UIMessages.ParentParts);
}
PlaceHolder1.Controls.Add(grd);
PlaceHolder1.Controls.Add(new LiteralControl(Constants.BREAKTAG));
grd.Rebind();
protected void grd_ItemDataBound(object sender, GridItemEventArgs e)
{
RadGrid senderGrid = (RadGrid)sender;
List<string> editabeColumns = (List<string>)_columnOrdinal[sender];
if (e.Item is GridDataItem)
{
GridDataItem dataItem = e.Item as GridDataItem;
if (e.Item.OwnerTableView.Columns.FindByUniqueNameSafe(Constants.DELETECOLUMN) != null)
{
ImageButton img = dataItem[Constants.DELETECOLUMN].Controls[0] as ImageButton;
if (dataItem[Constants.DELETECOLUMN].Controls.Count > 0)
{
//ECR ECRNumber = null;
//int ecrId = 0;
//if (ECRId.Length > 0 && ECRId != Constants.ZeroNumber)
//{
// ecrId = Convert.ToInt32(ECRId);
// using (var ecrManager = new ECRECOManager())
// {
// ECRNumber = ecrManager.FindECR(Convert.ToDecimal(ECRId));
// }
// string deleteMessage = UIMessages.Delete + " - " + UIMessages.FinancalLinfoEcNumber + " " + ECRNumber.EcrNumber;
// img.Attributes.Add(Constants.ONCLICK, string.Format(CultureInfo.CurrentUICulture, Constants.POPUPCONFIRM, senderGrid.ClientID, UIMessages.RADGRIDCONFIRMDELETEECRPARTSCRIPT, deleteMessage));
//}
//else
img.Attributes.Add(Constants.ONCLICK, string.Format(CultureInfo.CurrentUICulture, Constants.POPUPCONFIRM, senderGrid.ClientID, UIMessages.RADGRIDCONFIRMDELETEECRPARTSCRIPT, UIMessages.Delete));
//"if(!$find('" + senderGrid.ClientID + "').confirm('" + UIMessages.RADGRIDCONFIRMDELETEECRPARTSCRIPT + "', event, 'Delete'))return false;");
//dataItem[Constants.DELETECOLUMN].Attributes.Add(UIMessages.ONCLICK, string.Format(UIMessages.RADGRIDCONFIRMDELETEECRPARTSCRIPT, senderGrid.ClientID));
img.ToolTip = UIMessages.Delete;
if (dataItem["IsDeletable"].Text.Trim() == "0")
{
dataItem[Constants.DELETECOLUMN].Text = string.Empty;
}
}
if (senderGrid.Attributes[Constants.INDEXTEXT].Equals(Constants.ZeroNumber))
if ((dataItem.DataItem as DataRowView).Row.Table.Rows.Count == 1)
img.Visible = false;
}
if (e.Item.OwnerTableView.Columns.FindByUniqueNameSafe(Constants.EDITCOLUMN) != null)
{
if (dataItem[Constants.EDITCOLUMN].Controls.Count > 0)
{
ImageButton editBtn = (ImageButton)dataItem[Constants.EDITCOLUMN].Controls[0];
//editBtn.ToolTip = UIMessages.Edit;
editBtn.Visible = false;
}
}
}
if (e.Item is GridHeaderItem)
{
try
{
GridHeaderItem dataItem = e.Item as GridHeaderItem;
/* dataItem[Constants.PREECRPARTNUMBER].Style.Add("border-left", "2px solid #3663bd");
dataItem[Constants.ECRPARTNUMBER].Style.Add("border-left", "2px solid #3663bd");
dataItem[Constants.RELEASEDPARTNUMBER].Style.Add("border-left", "2px solid #3663bd");*/
dataItem.Style.Add("border-left", "2px solid #3663bd");
}
catch
{
}
}
GridEditableItem editedItem = e.Item as GridEditableItem;
//if (e.Item.IsInEditMode)
//{
// GridEditFormItem editform = (GridEditFormItem)e.Item;
// if (_ecr != null)
// {
// ((System.Web.UI.WebControls.TableCell)(editform.Controls[1].Controls[0].Controls[1].Controls[0].Controls[0].Controls[0])).Text =
// (_ecr.EcrState == Constants.ECRSTATUSINITIATE) ? "<b>" + UIMessages.ECREditHeader + "</b>" : "<b>" + UIMessages.ECOEditHeader + "</b>";
// }
// else
// {
// ((System.Web.UI.WebControls.TableCell)(editform.Controls[1].Controls[0].Controls[1].Controls[0].Controls[0].Controls[0])).Text =
// "<b>" + UIMessages.ECREditHeader + "</b><b>" + UIMessages.ECOEditHeader + "</b>";
// }
// // editform.EditFormCell.
//}
if (editedItem != null && e.Item.IsInEditMode)
{
//Find the row being edited in the session stored DataSet
decimal partID = Convert.ToDecimal(editedItem.GetDataKeyValue(Constants.PARTPRODUCTIONSOURCEID));
DataRow editRow = ECRPartsSession.Tables[senderGrid.ID].Select(string.Format(CultureInfo.InvariantCulture, Constants.SEARCHPARTFILTER, partID)).First();
//editedItem[Constants.AFFECTEDPART].Enabled = false;
//Fill editable TextBoxes
foreach (string columnName in editabeColumns)
{
//Fill ECRType DropDown
if (columnName.Equals(Constants.ECRTYPE))
{
string ecrType = editRow[Constants.ECRTYPE].ToString();
RadComboBox combo = (RadComboBox)editedItem.FindControl(senderGrid.ID + Constants.ECRTYPE);
combo.Focus();
if (combo != null)
{
FillAccessDropDown(combo, ecrType);
if (ecrType == Constants.ECRPARTLEVELTYPEPREECR)
{
//combo.SelectedIndex = combo.FindItemIndexByValue(Constants.ECRTYPEADD);
combo.SelectedValue = Constants.ECRTYPEADD;
}
else
{
//combo.SelectedIndex= combo.FindItemIndexByText("O");
combo.SelectedValue = ecrType == "O" ? "D" : ecrType;
}
}
}
//Fill ToolSource location DropDowns
else if (_toolSourcelocationColumns.Contains(columnName) && !Production)
{
if ((editedItem.OwnerTableView.AutoGeneratedColumns.Any(gc => gc.UniqueName == columnName)))
{
if (editedItem[columnName] != null) //&& editedItem[locationColumn].Controls.Count <= 1)
{
RadComboBox comboLocTool = (RadComboBox)editedItem.FindControl(senderGrid.ID + columnName);
if (comboLocTool != null)
{
FillLocation(comboLocTool, _toolSource, editRow[columnName]);
RadComboBoxItem foundItem = null;
string valueColumn = columnName.Replace(Constants.NAME, string.Empty);
foundItem = comboLocTool.FindItemByValue(Convert.ToString(((editedItem.DataItem as DataRowView))[valueColumn]));
if (comboLocTool.Items.Contains(foundItem))
{
comboLocTool.SelectedValue = foundItem.Value;// ((editedItem.DataItem as DataRowView))[valueColumn].ToString();
}
}
}
}
}
//Fill FixtureSource location DropDowns
else if (_fixtureSourcelocationColumns.Contains(columnName) && !Production)
{
if ((editedItem.OwnerTableView.AutoGeneratedColumns.Any(gc => gc.UniqueName == columnName)))
{
if (editedItem[columnName] != null) //&& editedItem[locationColumn].Controls.Count <= 1)
{
RadComboBox comboLocTool = (RadComboBox)editedItem.FindControl(senderGrid.ID + columnName);
if (comboLocTool != null)
{
FillLocation(comboLocTool, _fixtureSource, editRow[columnName]);
RadComboBoxItem foundItem = null;
string valueColumn = columnName.Replace(Constants.NAME, string.Empty);
foundItem = comboLocTool.FindItemByValue(Convert.ToString(((editedItem.DataItem as DataRowView))[valueColumn]));
if (comboLocTool.Items.Contains(foundItem))
{
comboLocTool.SelectedValue = foundItem.Value;// ((editedItem.DataItem as DataRowView))[valueColumn].ToString();
}
}
}
}
}
//Fill ProductionSource location DropDowns
else if (_productionSourcelocationColumns.Contains(columnName))
{
if ((editedItem.OwnerTableView.AutoGeneratedColumns.Any(gc => gc.UniqueName == columnName)))
{
if (editedItem[columnName] != null) //&& editedItem[locationColumn].Controls.Count <= 1)
{
RadComboBox comboLocProd = (RadComboBox)editedItem.FindControl(senderGrid.ID + columnName);
if (comboLocProd != null)
{
FillLocation(comboLocProd, _productionSource, editRow[columnName]);
RadComboBoxItem foundItem = null;
string valueColumn = columnName.Replace(Constants.NAME, string.Empty);
foundItem = comboLocProd.FindItemByValue(Convert.ToString(((editedItem.DataItem as DataRowView))[valueColumn]));
if (comboLocProd.Items.Contains(foundItem))
{
comboLocProd.SelectedValue = foundItem.Value;// ((editedItem.DataItem as DataRowView))[Constants.ECRPRODUCTIONSOURCE].ToString();
}
}
}
}
}
//Fill Date fields
else if (_dateFields.Contains(columnName) && Production)
{
if ((editedItem.OwnerTableView.AutoGeneratedColumns.Any(gc => gc.UniqueName == columnName)))
{
if (editedItem[columnName] != null) //&& editedItem[locationColumn].Controls.Count <= 1)
{
RadDatePicker rdpDate = editedItem[columnName].Controls[0] as RadDatePicker;
if (rdpDate != null)
{
if (!string.IsNullOrEmpty(Convert.ToString(editRow[columnName])))
rdpDate.SelectedDate = Convert.ToDateTime(Convert.ToString(editRow[columnName]));
if (columnName == Constants.BASELINEMRDTOPLANTDATE || columnName == Constants.BASELINEPPAPDATE)
{
rdpDate.ClientEvents.OnDateSelected = "GMS.Masters.ECR.Part.ecoBaselineDateSelected";
}
if (columnName == Constants.PLANMRDTOPLANTDATE || columnName == Constants.PLANPPAPDATE)
{
if (rdpDate.SelectedDate == null)
rdpDate.Attributes.Add("HasValue", "false");
else
rdpDate.Attributes.Add("HasValue", "true");
}
}
}
}
}
else
{
if ((editedItem.OwnerTableView.AutoGeneratedColumns.Any(gc => gc.UniqueName == columnName)))
{
if (editedItem[columnName] != null) //&& editedItem[columnName].Controls.Count <= 1)
{
RadTextBox txtBox = (RadTextBox)editedItem.FindControl(senderGrid.ID + columnName);
if (txtBox != null)
{
txtBox.Text = Convert.ToString(editRow[columnName]);
//txtBox.ClientEvents.OnValueChanged = "debugger;OnTextValueChanged();";
// txtBox.Attributes.Add("onchange", "debugger;return GMS.ECR.ManageEcrEco.OnTextValueChanged();");
}
}
}
}
}
}
}