【问题标题】:UltraWebGrid: How to use a drop-down list in a columnUltraWebGrid:如何在列中使用下拉列表
【发布时间】:2010-09-06 03:00:25
【问题描述】:

我正在使用 Infragistics 网格,但我很难将下拉列表用作我的列之一的值选择器。

我尝试阅读文档,但 Infragistics 的文档不太好。我也看过这个discussion,但没有运气。

到目前为止我在做什么:

col.Type = ColumnType.DropDownList;
col.DataType = "System.String";

col.ValueList = myValueList;

myValueList 在哪里:

ValueList myValueList = new ValueList();

myValueList.Prompt = "My text prompt";
myValueList.DisplayStyle = ValueListDisplayStyle.DisplayText;

foreach(MyObjectType item in MyObjectTypeCollection)
{
    myValueList.ValueItems.Add(item.ID, item.Text); // Note that the ID is a string (not my design)
}

当我查看页面时,我希望在该列的单元格中看到一个下拉列表,但我的列是空的。

【问题讨论】:

    标签: c# asp.net grid infragistics ultrawebgrid


    【解决方案1】:

    这是我的一个页面中的一个示例:

    UltraWebGrid uwgMyGrid = new UltraWebGrid();
    uwgMyGrid.Columns.Add("colTest", "Test Dropdown");
    uwgMyGrid.Columns.FromKey("colTest").Type = ColumnType.DropDownList;
    uwgMyGrid.Columns.FromKey("colTest").ValueList.ValueListItems.Insert(0, "ONE", "Choice 1");
    uwgMyGrid.Columns.FromKey("colTest").ValueList.ValueListItems.Insert(1, "TWO", "Choice 2");
    

    【讨论】:

      【解决方案2】:

      我找到了问题所在。

      该列必须允许更新。

      uwgMyGrid.Columns.FromKey("colTest").AllowUpdate = AllowUpdate.Yes;
      

      【讨论】:

        【解决方案3】:
            public void MakeCellValueListDropDownList(UltraWebGrid grid, string columnName, string valueListName, string[] listArray)
            {
                //Set the column to be a dropdownlist
                UltraGridColumn Col = grid.Columns.FromKey(columnName);            
                Col.Type = ColumnType.DropDownList;
                Col.DataType = "System.String";
        
                try
                {
                    ValueList ValList = grid.DisplayLayout.Bands[0].Columns.FromKey(columnName).ValueList;
                    ValList.DataSource = listArray;
                    foreach (string item in listArray)
                    {
                        ValList.ValueListItems.Add(item);
                    }
                    ValList.DataBind();
                }
                catch (ArgumentException)
                {
        
                }
            }
        

        【讨论】:

          猜你喜欢
          • 2010-11-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多