RADCombobox Multiple Parameters

6 posts, 1 answers
  1. Prithvi
    Prithvi avatar
    8 posts
    Member since:
    Jul 2007

    Posted 17 Jan 2011 Link to this post

    Hi,

    I am using autocomplete for a RADCombobox. 

    [OperationContract]
    public RadComboBoxData wpfSelectProgrammeFromClientDB(RadComboBoxContext context)
    {
    }

    In this service, I am using a SQL Query to fill a datatable.

    strSQLQuery = "SELECT pk_ProgrammeID,Title FROM Programme WHERE Title LIKE @prefixText";
    da = new SqlDataAdapter(strSQLQuery, ConfigurationManager.ConnectionStrings["DEMO"].ToString());
    da.SelectCommand.Parameters.Add("@prefixText", SqlDbType.VarChar, 50).Value = "%" + context.Text + "%";
    dt = new DataTable();
    da.Fill(dt);

    In my .aspx, I use

    <telerik:RadComboBox ID="rcbClientProgrammeTitle" Runat="server" EmptyMessage="Select a Title" EnableLoadOnDemand="true" 
                                    ShowMoreResultsBox="true" EnableVirtualScrolling="true" Skin="Windows7" 
                                    AutoPostBack="True" >
    <WebServiceSettings Method="SelectProgrammeFromClientDB" Path="LinkMedia.aspx.cs"/>
    </telerik:RadComboBox>

    I need to pass a second parameter to the SQL Query, like

    strSQLQuery = "SELECT pk_ProgrammeID,Title FROM Programme WHERE Title LIKE @prefixText AND Client = @Client";
    da = new SqlDataAdapter(strSQLQuery, ConfigurationManager.ConnectionStrings["DEMO"].ToString());
    da.SelectCommand.Parameters.Add("@prefixText", SqlDbType.VarChar, 50).Value = "%" + context.Text + "%";
    da.SelectCommand.Parameters.Add("@Client", SqlDbType.VarChar, 50).Value = " + WHAT DO I PASS HERE;
    dt = new DataTable();
    da.Fill(dt);

    OR is there any other alternative to do this. The @Client comes from a Query String which I am not able to access in the WCF Service.

    Can you please show me a demo of how to send multiple parameters to the Service or how to access the query string values from the page in the service.

    Thanks
    Prithvi
  2. Answer
    Yana
    Admin
    Yana avatar
    4841 posts

    Posted 17 Jan 2011 Link to this post

    Hi Prithvi,

    Please check this help article  - it demonstrates how to pass additional information to the web service.

    All the best,
    Yana
    the Telerik team
    Browse the vast support resources we have to jump start 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.
  3. Prithvi
    Prithvi avatar
    8 posts
    Member since:
    Jul 2007

    Posted 17 Jan 2011 Link to this post

    Hi Yana,

    Thanks for the reply. The example that you specified uses the code

    context["FilterString"] = eventArgs.get_text();

    How do I get this in my web service with RadComboBoxContext context

    public RadComboBoxData wpfSelectProgrammeFromClientDB(RadComboBoxContext context)
    {
    }

    I tried the following

    <telerik:RadTextBox ID="rtbClientID" runat="server" Visible="false"></telerik:RadTextBox>

    function OnClientItemsRequesting(sender, eventArgs) {
    var lblClientID = $find("<%# rtbClientID.ClientID %>");
    var clientIDText = lblClientID.get_text();
    var context = eventArgs.get_context();
    context["ClientID"] = clientIDText;
    }

    <telerik:RadComboBox ID="rcbClientProgrammeTitle" Runat="server" 
                        EmptyMessage="Select a Title" EnableLoadOnDemand="true" 
                                    ShowMoreResultsBox="true" EnableVirtualScrolling="true" Skin="Windows7" 
                                    OnClientItemsRequesting="OnClientItemsRequesting" >
                                <WebServiceSettings Method="wpfSelectProgrammeFromClientDB" Path="Services/AutoCompleteWebControl.svc"/>
    </telerik:RadComboBox>


    But the web service and autocomplete don't fire up for the combobox. Is there anything else I am missing.

    Thanks
    Prithvi
  4. Prithvi
    Prithvi avatar
    8 posts
    Member since:
    Jul 2007

    Posted 17 Jan 2011 Link to this post

    Thanks. I figured it out. I used

    context["ClientID"] = <%= Request.QueryString["ClientID"] %>

    to set the QueryString value to the context in the OnClientItemsRequesting() function.

    Thanks
    Prithvi
  5. Jeff
    Jeff avatar
    17 posts
    Member since:
    Apr 2008

    Posted 02 Oct 2012 Link to this post

    When you reference an article, the article should actually exist...
  6. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 03 Oct 2012 Link to this post

    Hi Jeff,

    Please excuse us for the inconvenience caused.
    The link below has been posted in January 2011 - more than an year ago.
    During this time we have made some changes in our online help and some of the links have been changed.

    We have fixed the link and you can use it now.
    Thank you for pointing our attention to this.

    Regards,
    Kalina
    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