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

Fill Drop downs on preRender

1 Answer 214 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Grigory
Top achievements
Rank 1
Grigory asked on 29 Feb 2012, 11:06 AM
Hello. I have a problem with dropdowns filling.

I have one RadComboBox in Command item Template and second in PagerTemplate : 
<CommandItemTemplate>
                <table cellpadding="0" cellspacing="5" class="grd-message-header">
                    <tr>
                        <td>
                            Messages : 
                            <telerik:RadComboBox ID="ddlMessageFolder" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlMessageFolder_IndexChanged" EnableLoadOnDemand="false" ShowMoreResultsBox="false" EnableVirtualScrolling="false">
                                <Items>
                                    <telerik:RadComboBoxItem Text="Inbox" Value="Inbox" />
                                    <telerik:RadComboBoxItem Text="Sent" Value="Sent" />
                                </Items>
                            </telerik:RadComboBox>
                        </td>

 <PagerTemplate>

<telerik:RadComboBox ID="ddlMoveToFolder" Runat="server"
                                            EnableLoadOnDemand="False" EnableVirtualScrolling="false" 
                                            ShowMoreResultsBox="False"  >
                                            <Items>
                                                <telerik:RadComboBoxItem Text="Select Folder" Value="Select Folder" />
                                            </Items>
                                        </telerik:RadComboBox> 
</PagerTemplate>

On RadGridPrerender event I fill this radcomboboxes : 

GridCommandItem cmdItem = (GridCommandItem)grdMessage.MasterTableView.GetItems(GridItemType.CommandItem)[0];
            GridPagerItem pagerItem = (GridPagerItem)grdMessage.MasterTableView.GetItems(GridItemType.Pager)[0];
            RadComboBox customFolderDDL = (RadComboBox)pagerItem.FindControl("ddlMoveToFolder");
            RadComboBox combo = (RadComboBox)cmdItem.FindControl("ddlMessageFolder");


            List<MessageFolder> messageFolderList = ctrlComm.GetFolderList(HttpContextStorage.CurrentUser.UserID);
            List<RadComboBoxItem> rItemList = new List<RadComboBoxItem>();
            foreach (var item in messageFolderList)
            {
                rItemList.Add(new RadComboBoxItem(item.MessageFolderName, item.MessageFolderID.ToString()));
                
            }
            combo.Items.AddRange(rItemList);   
            //customFolderDDL.Items.AddRange(rItemList);    

If I fill only one Combobox (combo) then there are all okay.
But If I remove comment on second Combobox (customFolderDDL) filling , than no one RadCombobox will be filled.

Comboboxes are founded correctly , and if I see combobox items on debugging there are Items but they are not showing on page.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 01 Mar 2012, 06:30 AM
Hello,

Try the following code in ItemCreated event to populate the ComboBox.
C#:
protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
 if (e.Item is GridCommandItem)
 {
  GridCommandItem cmdItem = (GridCommandItem)e.Item;
  RadComboBox combo= (RadComboBox)cmdItem.FindControl("ddlMessageFolder");
  // populate the combobox here
 }
 if (e.Item is GridPagerItem)
 {
  GridPagerItem pagerItem = (GridPagerItem)e.Item;
  RadComboBox customFolderDDL = (RadComboBox)pagerItem.FindControl("ddlMoveToFolder");
  //populate the combobox here
 }
}

-Shinu.
Tags
Grid
Asked by
Grigory
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or