This is a migrated thread and some comments may be shown as answers.

[Solved] GridDropDownColumn DropDownList height defaults to longer than the items list

1 Answer 144 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rob T
Top achievements
Rank 1
Rob T asked on 04 Dec 2009, 07:01 PM
By default it appears the GridDropDownColumn DropDownList height defaults to a particular height.  This ends up displaying blank space beneath the items in the DropDownList when there are only a few items in the list.

How do  i configure the GridDropDownColumn or its DropDownList to have a height that is equal to the size of the items in the list?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 Dec 2009, 01:35 PM
Hello Rob,

I assume that you have null values in the table, and that is the cause of showing blank spaces in dropdown. If that the case, give a try with following code and see whether it helps.

ASPX:
 
    <telerik:GridDropDownColumn HeaderText="Dropdown" UniqueName="Dropdown" DataField="Region" DataSourceID="SqlDataSource1" 
        ListValueField="Region" ListTextField="Region"
    </telerik:GridDropDownColumn> 

CS:
 
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode) 
        { 
            GridEditFormItem editItem = e.Item as GridEditFormItem; 
            RadComboBox combo = (RadComboBox)editItem["Dropdown"].Controls[0]; 
            foreach (RadComboBoxItem comboItem in combo.Items) 
            { 
                if (comboItem.Text == ""
                { 
                    comboItem.Visible = false
                } 
            } 
        } 
    } 

Feel free to share the comments,
Shinu.
Tags
Grid
Asked by
Rob T
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or