Fill ComboBox On the fly

Posted on 2009-04-24
Last Modified: 2012-06-27
I want to fill combo on the fly in a gridview like
Question by:ghoshsaikat83
    LVL 53

    Expert Comment

    The code is also on that page !
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Collections.Generic;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using DevExpress.Web.ASPxCallbackPanel;
    using DevExpress.Web.ASPxGridView;
    using DevExpress.Web.ASPxEditors;
    using DevExpress.Web.ASPxClasses; 
     public partial class GridEditing_FillComboOnFly : BasePage {
         protected void Page_Load(object sender, EventArgs e) {
             if(!IsPostBack && !IsCallback) {
         protected void grid_CellEditorInitialize(object sender, ASPxGridViewEditorEventArgs e) {
             if(!grid.IsEditing || e.Column.FieldName != "City") return;
             if(e.KeyValue == DBNull.Value || e.KeyValue == null) return;
             object val = grid.GetRowValuesByKeyValue(e.KeyValue, "Country");
             if(val == DBNull.Value) return;
             string country = (string)val;
             ASPxComboBox combo = e.Editor as ASPxComboBox;
             FillCityCombo(combo, country);
             combo.Callback += new CallbackEventHandlerBase(cmbCity_OnCallback);
         protected void FillCityCombo(ASPxComboBox cmb, string country) {
             if (string.IsNullOrEmpty(country)) return;
             List<string> cities = GetCities(country);
             foreach (string city in cities)
         List<string> GetCities(string country) {
             List<string> list = new List<string>();
             AccessDataSourceCities.SelectParameters[0].DefaultValue = country;
             DataView view = (DataView)AccessDataSourceCities.Select(DataSourceSelectArguments.Empty);
             for(int i = 0; i < view.Count; i++) {
             return list;
         protected void AccessDataSource1_Modifying(object sender, SqlDataSourceCommandEventArgs e) {
         private void cmbCity_OnCallback(object source, CallbackEventArgsBase e) {
             FillCityCombo(source as ASPxComboBox, e.Parameter);

    Open in new window

    LVL 26

    Expert Comment

    by:Anurag Thakur
    what is the issue the code is given in the link itself in C#, vb, aspx, and JS
    where can we help
    LVL 5

    Author Comment

    Hi Dhaest
    they are using some dll
    using DevExpress.Web.ASPxCallbackPanel;
    using DevExpress.Web.ASPxGridView;
    using DevExpress.Web.ASPxEditors;
    using DevExpress.Web.ASPxClasses;
    LVL 53

    Accepted Solution

    C# - Ajax Cascading DropDownList in GridView with databse in ASP.NET


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
    We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now