SqlDataSource Parameter Control ID from RadDatePicker Control within RadPanelBar

4 posts, 0 answers
  1. Ben
    Ben avatar
    10 posts
    Member since:
    Dec 2011

    Posted 06 Jun 2012 Link to this post

    Hi

    Hope you can help.
     
    I have a RadDatePicker control within a RadPanelBar . I need to assign the RadDatePicker control id to a sql select parameter, heres what I have so far...
    <telerik:RadPanelBar ID="pbRegister" runat="server">
    <Items>
    <telerik:RadPanelItem Text="Register" Value="Register">
    <ItemTemplate>
    <telerik:RadDatePicker ID="txtDate" runat="server" AutoPostBack="True" SelectedDate="2012-02-21" Width="150px">
    <Calendar UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" ViewSelectorText="x">
    </Calendar>
    <DateInput DisplayDateFormat="dd/MM/yyyy" DateFormat="dd/MM/yyyy" AutoPostBack="True"
    LabelWidth="" SelectedDate="2012-02-21">
    </DateInput>
    <DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>
    </telerik:RadDatePicker>
    </ItemTemplate>
    </telerik:RadPanelItem>
    </Items>
    </telerik:RadPanelBar>
    ------------------------------------------------------
    <asp:SqlDataSource ID="dsTGRegister" runat="server" ConnectionString=""
    SelectCommand="ext_Register" SelectCommandType="StoredProcedure"
    DataSourceMode="DataReader">
    <SelectParameters>
    <asp:ControlParameter ControlID='<%= pbRegister.FindItemByValue("Register").FindControl("txtDate").ClientID %>' Name="AttributeDate" PropertyName="SelectedDate" />
    </SelectParameters>
    </asp:SqlDataSource>


    Thanks in advance, Ben
  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 11 Jun 2012 Link to this post

    Hello Ben,

    I tested the case, but it seems there is a limitation in the SqlDataSource control - it cannot take parameters that reference controls nested in other controls.  This peculiarity is not specific to RadControls. You cold probably reproduce it with regular ASP controls as well.


    Regards,
    Peter
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ben
    Ben avatar
    10 posts
    Member since:
    Dec 2011

    Posted 11 Jun 2012 Link to this post

    Hi Peter,

    Thanks, I agree with your response. Have added the following in code behind to get around this:

    protected void dsTGRegister_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
    {
        RadPanelItem panelItem1 = (RadPanelItem)pbRegister.FindItemByText("Register");
        RadDatePicker txtDate = panelItem1.FindControl("txtDate") as RadDatePicker;
     
        DateTime AttDate = (DateTime)txtDate.SelectedDate;
        string paramDate = (string)AttDate.ToString("dd/MM/yyyy");
     
     
        dsTGRegister.SelectParameters["AttributeDate"].DefaultValue = paramDate;
    }



    Thanks, Ben
  5. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 11 Jun 2012 Link to this post

    Hello Ben,

    Thank you for sharing your solution in the forum.

    Greetings,
    Peter
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top