iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
I have a grid with 50 rows. I need to create one column that contains dropdowns, checkboxes, and textboxes based on certain criteria's from another column in the grid. How do I do this? I am trying to use the Initialize row event of the grid.
protected void WebGrid1_InitializeRow(object sender, ISNet.WebUI.WebGrid.RowEventArgs e) { WebGridCellCollection cells = e.Row.Cells; if (e.Row.Type == RowType.Record) { switch (cells.GetNamedItem("OptControl").Value.ToString()) { case "1": cells.GetNamedItem("Value").Column.EditType = EditType.TextBox; cells.GetNamedItem("Value").Column.ColumnType = ColumnType.Text; break; case "2": cells.GetNamedItem("Value").Column.EditType = EditType.Checkbox; cells.GetNamedItem("Value").Column.ColumnType = ColumnType.CheckBox; break; case "3": cells.GetNamedItem("Value").Column.EditType = EditType.DropdownList; WebValueList gridColumn = WebGrid1.RootTable.Columns.GetNamedItem("Value").ValueList; gridColumn.DataSource = xTranslate.GetTranslateDisplayListFromDataTable(cells.GetNamedItem("OptTranslate_Cd").Value.ToString(), "1", "2",false); gridColumn.DataValueField = "Key"; gridColumn.DataTextField = "Value"; break; } }
}
I’m afraid that it is not possible to have one column that contains dropdowns, checkboxes, and textboxes based on certain criteria from another column in the grid by using the code as shown in your initial post. From my experiment, I found out that once the EditType of a column is assigned to a certain EditType enumeration, then it will be applied to the entire cell within this column. For example, if case “1” statement is invoked (set EditType to TextBox), then no matter which case statement will be invoked on the next iteration, the EditType of “Value” column will be TextBox.
My idea to implement such scenario is by using the “Template” ColumnType. Within the CellTemplate, the dropdowns, checkboxes, and textboxes are added. During InitializeRow event, based on certain criteria from “OptControl” column, the Visibility of those controls is set so that only one control appear on the cell.
I made a simple experiment to prove whether my ideas can be implemented or not. Unfortunately, set the Visibility during InitializeRow event is not a good idea.
However, I managed to make a simple sample of such scenario where the Visibility of those control is bind to a value during InitializeDataSource. The sample is enclosed as attachment. Please have the sample tested on your end and let us know your feedback.
I understand that my sample is not a perfect one. I’d be happy to receive criticism, suggestions, ideas, or opinions from other member on this topic.
Hope this helps.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname