Need to add a edittype and columntype dynamically

1 reply. Last post: November 16, 2011 8:46 PM by Yudi
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback

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;
          }                     
    }
}

 

All times are GMT -5. The time now is 5:52 PM.
Previous Next