Grid data does not display after rebind()

3 posts, 1 answers
  1. Pete
    Pete avatar
    14 posts
    Member since:
    Jun 2010

    Posted 16 Dec 2010 Link to this post

    I'm attempting to perform server side filtering on a RadGrid.  I'm trying to follow your examples on filtering as well as some blog posts found here and here.  On intial page load I load the Grid using a SQL data set. This loads fine.  I then load filters for the status column of "All, Active, and Working".  These values match exactly to what is returned in the data. When I click on the filter for the status column the server side event is called but the data is removed from the grid. 
    Can you tell me what I'm doing wrong?

    <rad:RadGrid id="RadGrid1" 
     ShowStatusBar="true" runat="server" AllowPaging="False" AllowSorting="True"
     AllowMultiRowSelection="True" AutoGenerateColumns="false"  
     Width="100%"   Height="92%"  Skin="Windows7" AllowFilteringByColumn="true" EnableLinqExpressions="false">
            <MasterTableView PageSize="10" Width="100%" TableLayout="Fixed" EnableViewState="false">
                        <rad:GridTemplateColumn UniqueName="CheckBoxTemplateColumn"  
                                                    <asp:CheckBox id="headerChkbox" Text="Select All" OnCheckedChanged="ToggleSelectedState" AutoPostBack="True" runat="server"></asp:CheckBox>
                                                   <ItemTemplate >
                                                       <asp:CheckBox id="CheckBox1" OnCheckedChanged="ToggleRowSelection" AutoPostBack="True" runat="server" Width="65"></asp:CheckBox>
                                                   </ItemTemplate>                                            </rad:GridTemplateColumn>                                                         <rad:GridBoundColumn 
                                                   <ItemStyle />
                                                   HeaderText="ID"                                                 Visible="True"                                                   
                                                   <ItemStyle />
                                                   <ItemStyle />
                                                   AutoPostBackOnFilter="true" >
                                                   <ItemStyle />
                                                       <rad:RadComboBox ID="RadComboBoxStatus"  OnSelectedIndexChanged="FilterCombo_SelectedIndexChanged" 
                                                           DataValueField="STATUS" Width="70px"                                                          
                                                           AppendDataBoundItems="true">                                                         <Items>                                                             <rad:RadComboBoxItem Text="All"  Value="All" /> 
                                                               <rad:RadComboBoxItem Text="Active"  Value="Active"/> 
                                                               <rad:RadComboBoxItem Text="Working" Value="Working" />  
                                       <ClientSettings EnableRowHoverStyle="true" 
                                                       Resizing-EnableRealTimeResize ="false" 
                                                       Resizing-ClipCellContentOnResize ="false">                                                    
                                           <Scrolling AllowScroll ="true" UseStaticHeaders="true" />
                                           <ClientEvents OnColumnResized="OnColumnResized" />                                        
                                       <PagerStyle Mode="Slider"></PagerStyle>

    protected void FilterCombo_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) 
            string filterExpression;
            filterExpression = "([STATUS] = \'" + e.Text + "\')";
            RadGrid1.MasterTableView.FilterExpression = filterExpression;
  2. Answer
    Cori avatar
    562 posts
    Member since:
    Jul 2010

    Posted 16 Dec 2010 Link to this post

    Hello Pete,

    If you don't handle the OnNeedDataSource event, you can't call Rebind because it doesn't know what it's rebinding to. So you need to handle that event and pass it the DataSet you're using.

    I hope that helps.
  3. Pete
    Pete avatar
    14 posts
    Member since:
    Jun 2010

    Posted 17 Dec 2010 Link to this post

    Hello Cori,
    I added the OnNeedDataSource event and at first it didn't work (wasn't calling the radcombo box selection change).  I remembered the view state and set that to true (EnableViewState=true).
    Seems to be working now.
Back to Top