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

SqlDataSource Parameter Control ID from RadDatePicker Control within RadPanelBar

4 Answers 93 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 06 Jun 2012, 12:38 PM
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

4 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 11 Jun 2012, 12:28 PM
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.
0
Ben
Top achievements
Rank 1
answered on 11 Jun 2012, 12:38 PM
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
0
Peter
Telerik team
answered on 11 Jun 2012, 03:27 PM
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.
0
Matt
Top achievements
Rank 1
answered on 30 May 2018, 06:11 PM

You'd think that this:

        protected void SqlDataSource_Selecting(object sender, System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs e)
        {
            SqlDataSource.SelectParameters["startdate"].DefaultValue = RDP_StartDate.SelectedDate.ToString();
            SqlDataSource.SelectParameters["enddate"].DefaultValue = RDP_EndDate.SelectedDate.ToString();
        }

Would work... but it doesn't. =(

Tags
PanelBar
Asked by
Ben
Top achievements
Rank 1
Answers by
Peter
Telerik team
Ben
Top achievements
Rank 1
Matt
Top achievements
Rank 1
Share this question
or