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

No records after grouped rebind

2 Answers 41 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 25 Jul 2012, 07:26 AM
Hey Guys,
I have a radGrid bound to an object data source declaratively.  That source looks at a search box and a category dropdown for search parameters.  The search button calls a rebind.  Everything works great.

Until I turn grouping on.  The grouping works great on first page load, but on subsequent search button postbacks and therefore rebind() calls, there are no records found, even though that search works ok with grouping off.

Anyone know why this might be ?  Find my page below:

<fieldset>
        <legend>Search Help Centre</legend>
        <ul>
            <li>
                <label for="tbSearchText">Search text</label>
                <asp:TextBox ID="tbSearchText" runat="server" />
            </li>
            <li>
                <label for="catSelector">Category</label>
                <ah:CategorySelector ID="catSelector" runat="server" CategoryParentCat="Faq" InsertEmpty="All" />
            </li>
            <li> :</li>
            <li><label for="btnSearch"> </label><telerik:RadButton ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click" /></li>
        </ul>
    </fieldset>
 
    <telerik:RadGrid ID="rgFaq" runat="server" DataSourceID="objFaq" GroupingEnabled="true" OnItemDataBound="rgFaq_ItemDataBound" AllowPaging="True" PageSize="200" AllowSorting="False" AutoGenerateColumns="False">
        <MasterTableView DataKeyNames="kbId" ShowHeader="false">
            <GroupByExpressions>
                <telerik:GridGroupByExpression>
                    <GroupByFields>
                        <telerik:GridGroupByField FieldName="CategoryId" />
                    </GroupByFields>
                </telerik:GridGroupByExpression>
            </GroupByExpressions>
            <Columns>
                <telerik:GridTemplateColumn>
                    <ItemTemplate>
                        <%#Eval("kbTitle") %>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
         
    <asp:ObjectDataSource ID="objFaq" EnablePaging="true" SelectMethod="SearchFaqList" SelectCountMethod="SearchFaqList_Count" runat="server" TypeName="ArtsHub.BLL.Faq.Faq">
        <SelectParameters>
            <asp:ControlParameter ControlID="tbSearchText" DefaultValue="" Name="searchText" Type="String" ConvertEmptyStringToNull="false" />
            <asp:ControlParameter ControlID="catSelector" PropertyName="SelectedCategoryId" Name="CategoryId" Type="Int32" />
        </SelectParameters>
    </asp:ObjectDataSource>
protected void btnSearch_Click(object sender, EventArgs e)
{
    rgFaq.DataBind();
}
 
protected void rgFaq_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridGroupHeaderItem)
    {
        GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item;
        DataRowView groupDataRow = (DataRowView)e.Item.DataItem;
        item.DataCell.Text = groupDataRow["CategoryId"].ToString();
    }
}


Thanks for any help.

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 25 Jul 2012, 07:49 AM
Hello Simon,

Try setting the SelectFields collection in the GroupByExpressions. You have only set the GroupByFields collection in the GridGroupByExpression.
aspx:
<GroupByExpressions>
<telerik:GridGroupByExpression>
      <GroupByFields>
              <telerik:GridGroupByField FieldName="CategoryId" />
       </GroupByFields>
        <SelectFields>
           <telerik:GridGroupByField FieldName="CategoryId" />
       </SelectFields>
</telerik:GridGroupByExpression>
</GroupByExpressions>
Also check the following help documentation.
Declarative Definition.

Thanks,
Shinu.
0
Simon
Top achievements
Rank 1
answered on 25 Jul 2012, 07:54 AM
Thanks for such a quick response.  Magic, that was it.
Thanks again.
Tags
Grid
Asked by
Simon
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Simon
Top achievements
Rank 1
Share this question
or