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

combo box empty message in radgrid

4 Answers 107 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ron
Top achievements
Rank 1
Ron asked on 14 Oct 2013, 02:06 PM
Hi,

I'm using a rad combo within the grid control. I would like to set an empty message to display the text "Select item" when the page loads or if there's no item selected. But it does not work. I've done a some research on this and from everything I've read I'm supposed to set the "AllowCustomText=True". I've tried it both ways with no success. If I open the combobox and close it without selecting an item the empty message then shows but it doesn't show initially or on load. Can you help?
<telerik:GridTemplateColumn DataField="Item" UniqueName="Item">
                        <ItemStyle />
                        <ItemTemplate>
                          <telerik:RadComboBox ID="ddlItems" runat="server" AutoPostBack="false"
                                DataSourceID="objItems" DataTextField="Items" DataValueField="Items"
                                Skin="Default"  OnClientDropDownOpening="DropDownOpening"
                                OnClientSelectedIndexChanged="ItemValueChanged" EnableViewState="true"
                                AllowCustomText="False"   Width="150px" Height="150px" EmptyMessage="Select Item"
                                ondatabound="ddlItems_DataBound"
                                FocusedStyle-BackColor="#fff6dc" Text='<%# Eval("Item") %>'>
                            </telerik:RadComboBox>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
thanks,
Ron.

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 15 Oct 2013, 04:22 AM
Hi Ron,

Please remove the Text property of the RadComboBox and see if it helps.Please try the following code snippet.

ASPX:
<telerik:GridTemplateColumn DataField="Item" UniqueName="Item">  
    <ItemTemplate>
        <telerik:RadComboBox ID="ddlItems" runat="server" AutoPostBack="false" DataSourceID="objItems"
            DataTextField="Items" DataValueField="Items" Skin="Default" OnClientDropDownOpening="DropDownOpening"
            OnClientSelectedIndexChanged="ItemValueChanged" EnableViewState="true" AllowCustomText="False"
            Width="150px" Height="150px" EmptyMessage="Select Item" OnDataBound="ddlItems_DataBound"
            FocusedStyle-BackColor="#fff6dc">
        </telerik:RadComboBox>
    </ItemTemplate>
</telerik:GridTemplateColumn>

Thanks,
Princy
0
Ron
Top achievements
Rank 1
answered on 15 Oct 2013, 09:30 AM
Princy,

Thanks for replying but that did not work either. I also tried it with removing the text property and setting the AllowCustomText property to true and that also did not work. Any other suggestions?

Thanks,
0
Accepted
Princy
Top achievements
Rank 2
answered on 16 Oct 2013, 05:04 AM
Hi Ron,

The code works fine at my end,Below is the code I tried.

ASPX:
<telerik:GridTemplateColumn>
    <ItemTemplate>
        <telerik:RadComboBox ID="RadComboBox1" runat="server" DataSourceID="SqlDataSource1"
            DataTextField="ShipCountry" DataValueField="ShipCountry" AllowCustomText="true"
            EmptyMessage="-- Select item --">
        </telerik:RadComboBox>
    </ItemTemplate>
</telerik:GridTemplateColumn>

OR add from code behind as follows if it doesn't show from ASPX.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        RadComboBox combo = (RadComboBox)item.FindControl("RadComboBox1");
        combo.AllowCustomText = true;
        combo.EmptyMessage = "Select an Item";
    }
 }

Thanks,
Princy
0
Ron
Top achievements
Rank 1
answered on 22 Oct 2013, 10:17 AM
I was able to get it to work. Thank you.
Tags
Grid
Asked by
Ron
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Ron
Top achievements
Rank 1
Share this question
or