Completed
Last Updated: 25 Jun 2015 12:21 by ADMIN
ADMIN
Stefan
Created on: 05 Jan 2015 09:07
Category: GridView
Type: Bug Report
0
FIX. RadGridView - exception when filtering combo column, with string ValueMember and int FieldName
To reproduce, use this code:

            AddGrid();

            List<DropDownObject> lstDrp = new List<DropDownObject>();

            DropDownObject drpObj = new DropDownObject();
            drpObj.DropdownValue = "100";
            drpObj.DropdownValueID = 1;

            DropDownObject drpObj2 = new DropDownObject();
            drpObj2.DropdownValue = "100";
            drpObj2.DropdownValueID = 2;

            DropDownObject drpObj1 = new DropDownObject();
            drpObj1.DropdownValue = "101";
            drpObj1.DropdownValueID = 1;

            lstDrp.Add(drpObj);
            lstDrp.Add(drpObj2);
            lstDrp.Add(drpObj1);

            DataTable dtMain = new DataTable();
            DataColumn dcDropCol = new DataColumn();
            dcDropCol.ColumnName = "DropDown Col";
            dcDropCol.DataType = typeof(System.Int32);

            dtMain.Columns.Add(dcDropCol);

            DataRow dr = dtMain.NewRow();
            dr["DropDown Col"] = 100;
            dtMain.Rows.Add(dr);

            var uniqueDropdownValues = lstDrp.GroupBy(s => s.DropdownValue).Select(s => s.First());

            GridViewComboBoxColumn drpCol = new GridViewComboBoxColumn();
            radGridView1.Columns.Add(drpCol); //first add the column
            //drpCol.DataType = typeof(int); //then change its data type to change the filtering type from string to int

            drpCol.Name = "DropDown Col";
            drpCol.HeaderText = "Dropdown Col";
            drpCol.FieldName = "Dropdown Col";
            drpCol.DataSource = uniqueDropdownValues;
            drpCol.ValueMember = "DropdownValue";
            drpCol.DisplayMember = "DropdownValue";
            drpCol.Width = 200;
            
            drpCol.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDown;
            drpCol.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            drpCol.AllowFiltering = true;

            radGridView1.EnableFiltering = true;
            radGridView1.ShowHeaderCellButtons = true;

            radGridView1.DataSource = dtMain;

            radGridView1.AllowAddNewRow = true;
0 comments