?
Solved

Fill ComboBox On the fly

Posted on 2009-04-24
5
Medium Priority
?
1,313 Views
Last Modified: 2012-06-27
I want to fill combo on the fly in a gridview like
http://demos.devexpress.com/ASPxGridViewDemos/GridEditing/FillComboOnFly.aspx
0
Comment
Question by:ghoshsaikat83
  • 2
4 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 24222701
The code is also on that page !
Using
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) {
             grid.StartEdit(3);
         }
     }
 
     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);
         cmb.Items.Clear();
         foreach (string city in cities)
             cmb.Items.Add(city);
     }
     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++) {
             list.Add((string)view[i][0]);
         }
         return list;
     }
     protected void AccessDataSource1_Modifying(object sender, SqlDataSourceCommandEventArgs e) {
         DemoSettings.AssertNotReadOnly();
     }
 
     private void cmbCity_OnCallback(object source, CallbackEventArgsBase e) {
         FillCityCombo(source as ASPxComboBox, e.Parameter);
     }
 }

Open in new window

0
 
LVL 26

Expert Comment

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

Author Comment

by:ghoshsaikat83
ID: 24222731
Hi Dhaest
they are using some dll
using DevExpress.Web.ASPxCallbackPanel;
using DevExpress.Web.ASPxGridView;
using DevExpress.Web.ASPxEditors;
using DevExpress.Web.ASPxClasses;
0
 
LVL 53

Accepted Solution

by:
Dhaest earned 2000 total points
ID: 24222750
C# - Ajax Cascading DropDownList in GridView with databse in ASP.NET
http://csharpdotnetfreak.blogspot.com/2009/02/ajax-cascading-dropdownlist-database.html

0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month17 days, 13 hours left to enroll

831 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