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

Titlebar custom control problem

3 Answers 86 Views
Dock
This is a migrated thread and some comments may be shown as answers.
khathu
Top achievements
Rank 1
khathu asked on 16 Nov 2010, 01:25 PM
Hi,

I need to have a dropdown in the titlebar of my "Weather" dock widget and have it sending city values to my custom "Weather" control.
I am struggling to pass the slected value to my ObjectDataSource's ControlID. Is my request possible at all?

The dropdown works fine inside the Weather control but will look much better if its part of the dock's titlebar.

<telerik:RadDock ID="Weather" Runat="server" Width="300px" Skin="MyCustomSkin" EnableEmbeddedSkins="false" 
                                            EnableRoundedCorners="True" BackColor="#F3F3F3" 
BorderStyle="None" Title="Weather" AutoPostBack="True"  >
  
  
                                       <ContentTemplate>
                                                     <asp:UpdatePanel ID="UpdatePanel1" runat="server">
       <ContentTemplate
        
  
        <%-- INCLUDE CONTENT - WEATHER --%>
                           
                                        <content:Weather ID="Weather1" runat="server"></content:Weather></ContentTemplate>  
     </asp:UpdatePanel>
                                       </ContentTemplate>
                                    </telerik:RadDock>
  
  
  
  
<asp:XmlDataSource ID="XmlWeather" runat="server"></asp:XmlDataSource>
                                               <telerik:RadComboBox ID="CityList" Runat="server" AutoPostBack="true">
                                               <Items>
                                               <telerik:RadComboBoxItem Text="Bloemfontein" Value="Bloemfontein"  />
                                               <telerik:RadComboBoxItem Text="Cape Town" Value="Cape Town"/>
                                               <telerik:RadComboBoxItem Text="Durban" Value="Durban"/>
                                               <telerik:RadComboBoxItem Text="East London" Value="East London"/>
                                               <telerik:RadComboBoxItem Text="Johannesburg" Value="Johannesburg"/>
                                               <telerik:RadComboBoxItem Text="Nelspruit" Value="Nelspruit"/>
                                               <telerik:RadComboBoxItem Text="Pietermaritzburg" Value="Pietermaritzburg"/>
                                               <telerik:RadComboBoxItem Text="Polokwane" Value="Polokwane"/>
                                               <telerik:RadComboBoxItem Text="Port Elizabeth" Value="Port Elizabeth"/>
                                               <telerik:RadComboBoxItem Text="Pretoria" Value="Pretoria"/>
                                               </Items>
  
  
  
<asp:ObjectDataSource ID="WeatherFeed" runat="server" 
    SelectMethod="GetForecast" TypeName="xxx.Controls.Conditions">
    <SelectParameters>
        <asp:ControlParameter ControlID="CityList" Name="location" 
            PropertyName="SelectedValue" Type="String" />
    </SelectParameters>
</asp:ObjectDataSource>
 

3 Answers, 1 is accepted

Sort by
0
Accepted
Pero
Telerik team
answered on 19 Nov 2010, 08:20 AM
Hi Khathu,

The TitleBar template of the RadDock control is INamingContainer, which means the ObjectDataSource will not be able to find the control by passing the ID to the ControlID property. That's why you need to pass the UniqueID of the ComboBox.

So, please dynamically create the control parameter and get the ComboBox's UniqueID, and then assign it to the ControlID property of the parameter.

All the best,
Pero
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
khathu
Top achievements
Rank 1
answered on 22 Nov 2010, 09:54 AM
Hi Pero,

Your suggestion sent me in the right directiion and worked well. I was aable to assign the control parameter at run-time but my problem arose when I tried to do the following:

DropDownList ddl = (DropDownList)NewsFeed.FindControl("DropDownList1");
  
  
  
            if (IsPostBack)
            {
  
                ObjectDataSource1.SelectParameters.Clear();
                ControlParameter cp = new ControlParameter("name", ddl.ID, "SelectedValue");
                ObjectDataSource1.SelectParameters.Add(cp);
            }
            else
            {
                ControlParameter cp = new ControlParameter("name", ddl.ID, "SelectedValue");
                ObjectDataSource1.SelectParameters.Add(cp);
            }


I could not "FindControl" my way to the dropdownlist in the title template. I eventually went the way below:

 

 

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"

 

 

 

SelectMethod="Gethuman" TypeName="Test._Default">

 

 

 

<SelectParameters>

 

 

 

<asp:ControlParameter ControlID="ctl00$MainContent$NewsFeed$T$DropDownList1" Name="name"

 

 

 

PropertyName="SelectedValue" Type="String" />

 

 

 

</SelectParameters>

 

 

 

</asp:ObjectDataSource>

 



0
khathu
Top achievements
Rank 1
answered on 23 Nov 2010, 07:06 AM
Hi Pero,

i had missed something, your suggestion worked!!

Thanks,
Tags
Dock
Asked by
khathu
Top achievements
Rank 1
Answers by
Pero
Telerik team
khathu
Top achievements
Rank 1
Share this question
or