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

RadComboBox inside Grid PagerTemplate problem

2 Answers 47 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Karen
Top achievements
Rank 1
Karen asked on 17 Nov 2008, 09:59 PM
Hi all

I have a RadComboBox placed inside the PagerTemplate of RadGrid

<PagerTemplate>
                                    <br /><br />
                                    <table width="100%" cellpadding="0" cellspacing="0" border="0">
                                        <tr>
                                            <td align="left">
                                                Selected: &nbsp;
                                                <telerik:RadComboBox ID="ActionBox" SkinID="NotFixed" runat="server">
                                                    <Items>
                                                        <telerik:RadComboBoxItem Text="Delete" Value="1" />
                                                        <telerik:RadComboBoxItem Text="Mark as Read" Value="2" />
                                                        <telerik:RadComboBoxItem Text="Add to Black List" Value="3" />
                                                    </Items>
                                                </telerik:RadComboBox>
                                                &nbsp;
                                                <asp:Button ID="GoBtn" CssClass="SmallGreenBtn" OnClick="ActionGo_Clicked" runat="server" Text="Go" />
                                            </td>
                                            <td align="right">
                                                <asp:Panel runat="server" HorizontalAlign="Right" ID="NumericPagerPlaceHolder"></asp:Panel>
                                            </td>
                                        </tr>
                                    </table>  
                                </PagerTemplate>

And a button GoBtn which fires click event, I am getting the ComboBox from Pager using the following method

private RadComboBox GetActionBox()
        {
            GridItem pagerItem = InboxGrid.MasterTableView.GetItems(GridItemType.Pager)[0];
            RadComboBox ActionBox = (RadComboBox) pagerItem.FindControl("ActionBox");
            return ActionBox;
        }

It successfully finds the Combo but the selected value is always the first item's value in the Combo, I am stack with this and cannot move forward , any help is much appreciated.

I also fire OnItemDataBound event to add the numeric pager, (just for more info)

if (e.Item is GridPagerItem)
            {
                GridPagerItem gridPager = e.Item as GridPagerItem;
                Control numericPagerControl = gridPager.GetNumericPager();
                Control placeHolder = gridPager.FindControl("NumericPagerPlaceHolder");
                placeHolder.Controls.Add(numericPagerControl);
            }

Data binding is done during the page load inside if(!IsPostBack)

2 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 18 Nov 2008, 07:31 AM
Hello Karen,

The easiest way to get the combo is with FindControl directly for the NamingContainer of the sender object in your button click event handler:

RadComboBox ActionBox = (RadComboBox) ((Button)sender).NamingContainer.FindControl("ActionBox");

Since there is a top (by default not visible) pager in the grid, this code:

InboxGrid.MasterTableView.GetItems(GridItemType.Pager)[0];

will return the top pager.

Please try this and let me know about the result.


Greetings,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Karen
Top achievements
Rank 1
answered on 18 Nov 2008, 08:23 AM
Thank you so much Vlad, that helped me a lot, everything worked!
Tags
Grid
Asked by
Karen
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Karen
Top achievements
Rank 1
Share this question
or