Since the version 14.1.20141.2283 upgrade, clicking a link button inside a Template Item does not fire the ItemCommand method when a webdatagrid is set to EnableDataViewState="true". If I set EnableDataViewState="false" and rebind the grid each postback the ItemCommand method fires as expected. This behavior was not occurring in the previous version of 14.1. Is this a known error? How can I fix it with rebinding my grids on each postback?
Hello Jason D, I call EnsureTemplates as you suggested in this thread. But It only working in the first post back. I do not understand what is happening,
You can help me?
Thank you!
Hello Nguyen,
I have tested this in our latest service release for v16.1 which is 2044 and it is working for me. What version are you using, including the service release? Do you have a sample that demonstrates the behavior you are seeing?
Hello Mike,
I'm using v15.5 and I set EnableViewState = true; EnableDataViewState = true in WebdatagridInit.
In PageLoad I also added code
if (IsPostBack) {
WebDataGrid1.EnsureTemplates();}
But when webdatagrid change the datasource then ItemCommand not working.
I have tested this with both the latest version of v15.1 (2400) and v15.2 (2195) and I have been unable to reproduce the issue you describe. Please attach a sample demonstrating the behavior you are seeing.
In WebDataGrid I set
protected void WebDataGrid1_Init(object sender, EventArgs e) { WebDataGrid grid = sender as WebDataGrid;
//列の自動作成をしない grid.AutoGenerateColumns = false; grid.DataKeyFields = "社員CD"; grid.EnableViewState = true; grid.EnableDataViewState = true; //grid.EnableAjaxViewState = true; //grid.EnableAjax = false; //grid.ClientEvents.Click = "WebDataGrid1_Click"; //grid.ClientEvents.AJAXResponse = "AJAXResponse"; grid.ClientEvents.KeyDown = "WebDataGrid1_Grid_KeyDown"; grid.RowUpdating += new Infragistics.Web.UI.GridControls.RowUpdatingHandler(WebDataGrid1_RowUpdating); grid.InitializeRow += this.WebDataGrid1_InitializeRow; grid.ItemCommand += this.WebDataGrid1_ItemCommand; grid.ActiveCellChanged += this.WebDataGrid1_ActiveCellChanged;
// コントロール レベルで Ajax インジケーターを有効にします grid.AjaxIndicator.Enabled = Infragistics.Web.UI.DefaultableBoolean.True; // Ajax インジケーター表示時にマスクをかける。 grid.AjaxIndicator.BlockArea = Infragistics.Web.UI.AjaxIndicatorBlockArea.Page; // Ajax インジケーターの位置を設定します grid.AjaxIndicator.Location = Infragistics.Web.UI.RelativeLocation.MiddleCenter; // コントロール固有の Ajax インジケーターの位置を設定します grid.AjaxIndicator.RelativeToControl = Infragistics.Web.UI.DefaultableBoolean.True;
//セルのアクティブ化の有効化 if (grid.Behaviors.Activation == null) { Activation aActivation = new Activation(); aActivation.ActiveCellCssClass = "ActiveCellSelector"; aActivation.ActivationClientEvents.ActiveCellChanging = "ActiveCellChanging"; // 動作コレクションに追加します grid.Behaviors.Add(aActivation); }
//セル編集機能の有効化 if (grid.Behaviors.EditingCore == null) { EditingCore aEditingCore = new EditingCore(); aEditingCore.AutoCRUD = false; aEditingCore.BatchUpdating = true; aEditingCore.Behaviors.CreateBehavior<Infragistics.Web.UI.GridControls.CellEditing>(); aEditingCore.Behaviors.CellEditing.EditModeActions.MouseClick = Infragistics.Web.UI.GridControls.EditMouseClickAction.Single; aEditingCore.Behaviors.CellEditing.EditModeActions.EnableOnKeyPress = true; aEditingCore.EditingClientEvents.CellValueChanging = "CellValueChanging"; aEditingCore.EditingClientEvents.CellValueChanged = "CellValueChanged"; aEditingCore.Behaviors.CellEditing.CellEditingClientEvents.EnteringEditMode = "EnteringEditMode"; // 動作コレクションに追加します grid.Behaviors.Add(aEditingCore); }
//列固定化の有効化 if (grid.Behaviors.ColumnFixing == null) { ColumnFixing ColumnFixingbehavior = new ColumnFixing(); ColumnFixingbehavior.FixLocation = FixLocation.Left; ColumnFixingbehavior.AutoAdjustCells = false; ColumnFixingbehavior.ShowFixButtons = false;
// 動作コレクションに追加します grid.Behaviors.Add(ColumnFixingbehavior); }
//グリッドで選択動作を有効にします。 if (grid.Behaviors.Selection == null) { Selection aSelection = new Selection(); aSelection.CellClickAction = CellClickAction.Cell; aSelection.CellSelectType = SelectType.Multiple;
// 動作コレクションに追加します grid.Behaviors.Add(aSelection); } }
First, I set all column is BoundDataField,
for (int i = 0; i < GridData.Instance.ColumnCount; i++) { string key = COLUMN_DEFAULT + i; BoundDataField gridField = new BoundDataField(true); gridField.Key = key; gridField.DataFieldName = key; gridField.Header.CssClass = "hidden"; gridField.CssClass = "HorizontalAlign_Left";
aWebDataGrid.Columns.Add(gridField);
}
After, I set again Template in InitializeRow.
protected void WebDataGrid1_InitializeRow(object sender, Infragistics.Web.UI.GridControls.RowEventArgs e) { WebDataGrid grid = (WebDataGrid)sender; //Set Height if (GridData.Instance[e.Row.Index].Height > 0) e.Row.Height = GridData.Instance[e.Row.Index].Height;
//Set template item int start = 1; for (int i = start; i < grid.Columns.Count; i++) { int rowIndex = e.Row.Index; int columnIndex = i - 1;
if (GridData.Instance.ShowType.GetValue() == Common.Master.C_ShowType.LANDSCAPE) { rowIndex = i - 1; columnIndex = e.Row.Index; }
CellData rCell = GridData.Instance[rowIndex, columnIndex];
e.Row.Items[i].CssClass = rCell.ClassCss; //Set Backgound if (!string.IsNullOrEmpty(rCell.BackColor)) e.Row.Items[i].CssClass = e.Row.Items[i].CssClass + rCell.BackColor;
CellType cellType = rCell.CellType; if (cellType == CellType.BOUNDDATAFIELD) { if (rCell.Locked) e.Row.Items[i].Template = new LabelTemplate(e.Row.Items[i].Column.Key); } else if (cellType == CellType.COMBOBOX) { DropDownTemplate template = rCell.Template as DropDownTemplate; if (rCell.Locked) template.Locked = true; e.Row.Items[i].Template = template; } else if (cellType == CellType.RADIOBUTTON) { RadioButtonTemplate template = rCell.Template as RadioButtonTemplate; if (rCell.Locked) template.Locked = true; e.Row.Items[i].Template = template; } else if (cellType == CellType.LINKBUTTON) { LinkButtonTemplate template = rCell.Template as LinkButtonTemplate; if (rCell.Locked) template.Locked = true; e.Row.Items[i].Template = template; } } }
Linkbutton ItemCommand still working, but when datasource grid change then ItemCommand not working.
Please help me. Thank you!
I am still unable to reproduce the behavior you describe. I am attaching my sample. Please either modify my sample or attach your own sample that reproduces the behavior you are seeing.