This is a migrated thread and some comments may be shown as answers.
ControlParameter with ToolBar and ComboBox
1 Answer 43 Views
This is a migrated thread and some comments may be shown as answers.
arubbert
Top achievements
Rank 1
arubbert asked on 17 Mar 2011, 10:30 PM
Hi,
I have the problem that this error pops up:
Could not find control 'EisDefaultLocationComboBox' in ControlParameter 'LocationID'.

Here my code:

<telerik:RadDockZone ID="EisDefaultDockZone" runat="server" Orientation="Vertical" Style="border: 0px;">
    <telerik:RadDock ID="EisDefaultDock" runat="server" Title="Employee Information System" EnableRoundedCorners="true"
        DefaultCommands="None" EnableDrag="false">
        <ContentTemplate>
            <telerik:RadToolBar ID="EisDefaultToolBar" runat="server" Width="100%" Style="margin-top: 6px;">
                <Items>
                    <telerik:RadToolBarButton Text="New User" Enabled="false" />
                    <telerik:RadToolBarButton Text="Print" Enabled="false" />
                    <telerik:RadToolBarButton Text="Help" Enabled="false" />
                    <telerik:RadToolBarButton IsSeparator="true" />
                    <telerik:RadToolBarButton>
                        <ItemTemplate>
                            <div style="padding-left: 75px;">
                                Location: 
                                <telerik:RadComboBox ID="EisDefaultLocationComboBox" runat="server" AutoPostBack="true"
                                    DataSourceID="EisMainListLocationDataSource" DataTextField="LocationName"
                                    DataValueField="LocationID" AppendDataBoundItems="true" Width="150px">
                                    <Items>
                                        <telerik:RadComboBoxItem Text="ALL" Value="0" Selected="true" />
                                    </Items>
                                </telerik:RadComboBox>
                            </div>
                        </ItemTemplate>
                    </telerik:RadToolBarButton>
                    <telerik:RadToolBarButton>
                        <ItemTemplate>
                            <div style="padding-left: 50px;">
                                Search: 
                                <telerik:RadTextBox ID="EisDefaultSearchTextBox" runat="server" Width="150px" Enabled="false" />
                            </div>
                        </ItemTemplate>
                    </telerik:RadToolBarButton>
                </Items>
            </telerik:RadToolBar>
            <telerik:RadGrid ID="YawaMainGrid" runat="server" DataSourceID="EisMainListDataSource" GridLines="None"
                AllowPaging="True" PageSize="20" AllowSorting="True" AutoGenerateColumns="False" ShowStatusBar="True"
                EnableHeaderContextMenu="True" EnableHeaderContextFilterMenu="True" AllowFilteringByColumn="True"
                OnItemCommand="YawaMainGrid_ItemCommand" OnItemDataBound="YawaMainGrid_ItemDataBound" Style="margin-top: 6px;">
                <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="false">
                    <Selecting AllowRowSelect="true" />
                    <ClientEvents OnRowClick="YawaMainGridRowClick" OnRowContextMenu="RowContextMenu" />
                </ClientSettings>
                <GroupingSettings CaseSensitive="false" />
                <MasterTableView DataSourceID="EisMainListDataSource" DataKeyNames="UserID" ClientDataKeyNames="UserID"
                    AllowFilteringByColumn="true" IsFilterItemExpanded="false">
                    <Columns>
                        <telerik:GridBoundColumn DataField="Account" 
                            FilterControlAltText="Filter Account column" HeaderText="Account" ReadOnly="true"
                            SortExpression="Account" UniqueName="Account">
                            <ItemStyle Width="65px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Lastname" 
                            FilterControlAltText="Filter Lastname column" HeaderText="Lastname" ReadOnly="true"
                            SortExpression="Lastname" UniqueName="Lastname">
                            <ItemStyle Width="160px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Firstname" 
                            FilterControlAltText="Filter Firstname column" HeaderText="Firstname" ReadOnly="true"
                            SortExpression="Firstname" UniqueName="Firstname">
                            <ItemStyle Width="120px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Loc." 
                            FilterControlAltText="Filter Loc. column" HeaderText="Loc." ReadOnly="true"
                            SortExpression="Loc." UniqueName="Loc.">
                            <ItemStyle Width="50px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="SBU/Dep." 
                            FilterControlAltText="Filter SBU/Dep. column" HeaderText="SBU/Dep." ReadOnly="true"
                            SortExpression="SBU/Dep." UniqueName="SBU/Dep.">
                            <ItemStyle Width="140px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Phone" 
                            FilterControlAltText="Filter Phone column" HeaderText="Phone" ReadOnly="True" 
                            SortExpression="Phone" UniqueName="Phone">
                            <ItemStyle Width="160px" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Phone" 
                            FilterControlAltText="Filter Mobile column" HeaderText="Mobile" ReadOnly="True" 
                            SortExpression="Mobile" UniqueName="Mobile">
                            <ItemStyle Width="160px" />
                        </telerik:GridBoundColumn>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>
            <telerik:RadContextMenu ID="EisDefaultContextMenu" runat="server" OnClientItemClicked="ClientMenuItemClick" EnableShadows="true">
                <Items>
                    <telerik:RadMenuItem Text="Full Details" Value="details" Enabled="true" />
                    <telerik:RadMenuItem Text="Edit" Value="edit" Enabled="false" />
                    <telerik:RadMenuItem Text="Set status" Value="status" Enabled="false" />
                </Items>
            </telerik:RadContextMenu>
        </ContentTemplate>
    </telerik:RadDock>
</telerik:RadDockZone>
<asp:SqlDataSource ID="EisMainListDataSource" runat="server"
    ConnectionString="<%$ ConnectionStrings:YAWAConnectionString %>" 
    SelectCommand="if (@LocationID <> 0)
                 begin
                   SELECT CoreUser.CoreUserID AS UserID,
                   CoreUser.UserAccount AS Account,
                   CoreUser.UserLastname AS Lastname,
                   CoreUser.UserFirstname AS Firstname,
                   CoreLocation.CoreLocationID AS LocationID,
                   CoreLocation.LocationNameShort AS [Loc.],
                   CoreBusinessUnit.BusinessUnitNameShort AS [SBU/Dep.],
                   REPLACE(CoreCountry.CountryAreaCode, '00', '+') + ' ' + RIGHT(CoreLocation.LocationAreaCode , LEN(CoreLocation.LocationAreaCode)-1) + ' ' + CoreLocation.LocationPhone + ' - ' + CoreUser.UserPhoneExtension AS Phone
                   FROM CoreUser
                   INNER JOIN CoreLocation ON CoreUser.CoreLocationID = CoreLocation.CoreLocationID
                   INNER JOIN CoreGfsExpenseCode ON CoreUser.CoreGfsExpenseCodeID = CoreGfsExpenseCode.CoreGfsExpenseCodeID
                   INNER JOIN CoreBusinessUnit ON CoreGfsExpenseCode.CoreBusinessUnitID = CoreBusinessUnit.CoreBusinessUnitID
                   INNER JOIN CoreCountry ON CoreLocation.CoreCountryID = CoreCountry.CoreCountryID
                   WHERE (CoreLocation.CoreLocationID = @LocationID)
                 end else begin
                   SELECT CoreUser.CoreUserID AS UserID,
                   CoreUser.UserAccount AS Account,
                   CoreUser.UserLastname AS Lastname,
                   CoreUser.UserFirstname AS Firstname,
                   CoreLocation.CoreLocationID AS LocationID,
                   CoreLocation.LocationNameShort AS [Loc.],
                   CoreBusinessUnit.BusinessUnitNameShort AS [SBU/Dep.],
                   REPLACE(CoreCountry.CountryAreaCode, '00', '+') + ' ' + RIGHT(CoreLocation.LocationAreaCode , LEN(CoreLocation.LocationAreaCode)-1) + ' ' + CoreLocation.LocationPhone + ' - ' + CoreUser.UserPhoneExtension AS Phone
                   FROM CoreUser
                   INNER JOIN CoreLocation ON CoreUser.CoreLocationID = CoreLocation.CoreLocationID
                   INNER JOIN CoreGfsExpenseCode ON CoreUser.CoreGfsExpenseCodeID = CoreGfsExpenseCode.CoreGfsExpenseCodeID
                   INNER JOIN CoreBusinessUnit ON CoreGfsExpenseCode.CoreBusinessUnitID = CoreBusinessUnit.CoreBusinessUnitID
                   INNER JOIN CoreCountry ON CoreLocation.CoreCountryID = CoreCountry.CoreCountryID
                 end">
    <SelectParameters>
        <asp:ControlParameter Name="LocationID" PropertyName="SelectedValue" ControlID="EisDefaultLocationComboBox" />
    </SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="EisMainListLocationDataSource" runat="server"
    ConnectionString="<%$ ConnectionStrings:YAWAConnectionString %>"
    SelectCommand="SELECT CoreLocation.CoreLocationID AS LocationID,
                   CoreLocation.LocationName AS LocationName
                   FROM CoreLocation">
</asp:SqlDataSource>

I want to filter the RadGrid with the RadComboBox shown in the Telerik Demo
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridcomboajax/defaultcs.aspx?product=grid

Could anyone help me please, I´m a beginner and want to learn ;-)

Andreas

1 Answer, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 22 Mar 2011, 06:45 PM
Hello Arubbert,

The error you are receiving is due to the fact, that the ClientID of the combobox is slightly changed, since it's situated in a template. In order to deal with this situation, you should add the following code in the Page_Load event:
ControlParameter controlParameter = new ControlParameter();
RadToolBar toolbar = (RadToolBar)EisDefaultDockZone.Docks[0].ContentContainer.FindControl("EisDefaultToolBar");
RadToolBarButton templateButton = (RadToolBarButton)toolbar.Items[4];
controlParameter.ControlID = templateButton.FindControl("EisDefaultLocationComboBox").UniqueID;
controlParameter.PropertyName = "SelectedValue";
controlParameter.Name = "LocationID";
EisMainListDataSource.SelectParameters.Add(controlParameter);

With the above provided code, we are getting reference to the UniqueID of the ComboBox, which is then set to the ControlID property of the ControlParameter. Please note that you should remove the following markup from your page since we are adding this ControlParameter programmatically:
<SelectParameters>
        <asp:ControlParameter Name="LocationID" PropertyName="SelectedValue" ControlID="EisDefaultLocationComboBox" />
    </SelectParameters>


Best wishes,
Dimitar Terziev
the Telerik team
Asked by
arubbert
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Share this question
or