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)
{
   base.OnInit(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;
   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)
   {
      o.DataBindItems();
   }
}


Last modified by Mohit @ 4/7/2025 8:25:48 AM