Not logged in - Login

Implement a combo box control in an editable ASPxGridView grid

Implement a combo box control in an editable grid.

Inside the OnInit() method, set the data source for the list in the combo box control:

protected override void OnInit(EventArgs e)

   //Load combo box table list
   DataTable tbl = this.ProjectsTbl;

   // get the grid column.
   DevExpress.Web.ASPxGridView.GridViewDataComboBoxColumn col = 
      this.grd.Columns["sProjectID"] as DevExpress.Web.ASPxGridView.GridViewDataComboBoxColumn;

   // make sure we got a valid reference to the column
   if (col != null)
      // set the data source for the column.
      col.PropertiesComboBox.DataSource = tbl;

Inside the CellEditorInitialize() event of the grid, bind the data items on the combo box:

protected void grd_CellEditorInitialize(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewEditorEventArgs e)
   //check if the current cell is a Combo box,then bind the data
   DevExpress.Web.ASPxEditors.ASPxComboBox o = e.Editor as DevExpress.Web.ASPxEditors.ASPxComboBox;
   if (o != null)