Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
639
Set Dropdown for a column of Ultragrid
posted

Hi all,

I have a ultragrid let user to update directly, I would like to set 1 of the column as dropdown selection to update data. The data of the dropdown will be get from a data source, how should I code for this condition?

I found from the community, most of the sample is assign data with hardcode method like below, can you all please suggest me a method which data retrive by data source?

private void BindUltraDropDown()
{
    DataTable dt = new DataTable();
    dt.Columns.Add("ID", typeof(int));
    dt.Columns.Add("DisplayText", typeof(string));

    dt.Rows.Add(new object[] {1, "A"});
    dt.Rows.Add(new object[] {2, "B"});
    dt.Rows.Add(new object[] {3, "C"});
    dt.AcceptChanges();

    this.ultraDropDown1.SetDataBinding(dt, null);
    this.ultraDropDown1.ValueMember = "ID";
    this.ultraDropDown1.DisplayMember = "DisplayText";
}


Thank you very much!

 

 

Parents
No Data
Reply
  • 469350
    Offline posted

    Hi,

    This code is creating a DataTable in code and assigning it to the UltraDropDown as it's data source.

    If you want to get your data from a database, instead, then there are a number of ways you can do that, but none of them really have anything to do with the grid or the DropDown. For detailed documentation on how to retrieve data from a database, you will need to check Microsoft's documentation.

    The typical way to do it using DataSets and DataTable is to use the DataAdapter class to fill those objects via a Connection.

    Binding the UltraDropDown and binding the WinGrid (or any other control) is essentially the same, though. So you could check the online help and I am pretty sure there are a couple of simple examples of how to bind the grid to a data source using an Access database file or SQL Server.

    Here's a link to the help where this is discussed.

    Accessing Data

     

Children