[Sitefinity 4.4] RadGrid controlled by combobox

Posted by Community Admin on 03-Aug-2018 16:15

[Sitefinity 4.4] RadGrid controlled by combobox

All Replies

Posted by Community Admin on 02-Mar-2012 00:00

Hello
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">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="sfGrid">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="sfGrid" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
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>
        <Columns>
            <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>
        </Columns>

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

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

<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
<WebServiceSettings>
<ODataSettings InitialContainerName=""></ODataSettings>
</WebServiceSettings>
</HeaderContextMenu>
</telerik:RadGrid>


<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">
    <SelectParameters>
        <asp:Parameter Type="Int16" DefaultValue="0" Name="siteId" />
    </SelectParameters>
</asp:SqlDataSource>

<asp:SqlDataSource ID="src" runat="server"
    ConnectionString="<%$ ConnectionStrings:tcdcConnectionString %>"
    SelectCommand="SELECT distinct idsito, ut.ID, st.site 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>

Posted by Community Admin on 06-Mar-2012 00:00

diego,

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!

Geoff.

Posted by Community Admin on 06-Mar-2012 00:00

Hello, Geoff
Thanx for your answer.
In effects, I forgot to DataBind...what a shame...
Regards
Diego

This thread is closed