More in this section

Forums / General Discussions / [Sitefinity 4.4] RadGrid controlled by combobox

[Sitefinity 4.4] RadGrid controlled by combobox

3 posts, 0 answered
  1. diego
    diego avatar
    19 posts
    13 Jul 2011
    02 Mar 2012
    Link to this post
    I am new in Sitefinity
    I have to build a page in which a RadGrid is controlled by a combo box; that is, from the combo I select an Item whose value will populate the grid
    When I select the item frfom the combo, the grid is correctly filled but when I click on the page navigator, it seems that the selection made is lost and no data appear in the grid
    Here following is the code of the control
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SubmittedFiles.ascx.cs" Inherits="SitefinityWebApp.Modules.Controls.SubmittedFiles" %>

    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
        <!-- content start -->

    And here i the code behind for the combo selected index

    protected void combo_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
                idSite = int.Parse(combo.SelectedValue);
                SqlDataSource1.SelectParameters["siteId"].DefaultValue = idSite.ToString();

    Thanks in advance

    Diego Polidori
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                        <telerik:AjaxSetting AjaxControlID="sfGrid">
                                <telerik:AjaxUpdatedControl ControlID="sfGrid" />
    Please, select a site&nbsp;&nbsp;<telerik:RadComboBox ID="combo" runat="server" DataSourceID="src"
        DataTextField="site" DataValueField="idsito"
         AutoPostBack="true" onselectedindexchanged="combo_SelectedIndexChanged"></telerik:RadComboBox>
        <br /><br />
    <telerik:RadGrid ID="sfGrid" runat="server" DataSourceID="SqlDataSource1"
        AllowPaging="True" AutoGenerateColumns="False"
        onitemcommand="sfGrid_ItemCommand" CellSpacing="0" GridLines="None" >
        <PagerStyle Mode="NextPrevAndNumeric" />
        <MasterTableView CellPadding="5" TableLayout="Auto" Width="100%">

    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>

    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
                <telerik:GridBoundColumn DataField="nome" HeaderText="File Name"></telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="info" HeaderText="Description"></telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="date" HeaderText="Submit Date" DataFormatString="{0:dd/MM/yyyy}"></telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="sname" HeaderText="Submitter Name"></telerik:GridBoundColumn>
               <telerik:GridButtonColumn ButtonType="LinkButton" Text="Download" CommandName="download"></telerik:GridButtonColumn>

    <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>

    <FilterMenu EnableImageSprites="False">
    <ODataSettings InitialContainerName=""></ODataSettings>

    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
    <ODataSettings InitialContainerName=""></ODataSettings>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:tcdcConnectionString %>" ProviderName="System.Data.SqlClient" SelectCommand="SELECT nome, [data info] as info, [data type] as type, date, imported, ut.NAME as sname FROM [tcdc].[dbo].[ifiles], tcdc.dbo.utenti ut where site=@siteId and [data type] is not null and idins=ut.ID and (nome not like '%l3%' and nome not like '%l4%' and nome not like '%BCKUP%' and nome not like '%CarboeuropeIP_remark%') order by date desc, [data type] asc">
            <asp:Parameter Type="Int16" DefaultValue="0" Name="siteId" />

    <asp:SqlDataSource ID="src" runat="server"
        ConnectionString="<%$ ConnectionStrings:tcdcConnectionString %>"
        SelectCommand="SELECT distinct idsito, ut.ID, FROM [tcdc].[dbo].[usersites] us, [tcdc].[dbo].[utenti] ut, tcdc.dbo.sites st where iduser=ut.ID and tipo!='U' and (ut.ID=25) and st.ID=idsito and site is not null and hide=0 order by site"></asp:SqlDataSource>
  2. Geoff
    Geoff avatar
    1 posts
    05 Mar 2012
    06 Mar 2012
    Link to this post

    Just a quick response, Have you turned on 'Enable ViewState' on the page to which the controls is being used? And possibly sfGrid.DataBind on your selection!

  3. diego
    diego avatar
    19 posts
    13 Jul 2011
    06 Mar 2012
    Link to this post
    Hello, Geoff
    Thanx for your answer.
    In effects, I forgot to DataBind...what a shame...
3 posts, 0 answered