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

RadGrid not showing the updated data,in accordance with the datasource

1 Answer 138 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dilip
Top achievements
Rank 1
Dilip asked on 28 Nov 2011, 11:41 AM

Hi,

I have a page with the radgrid ,which is coded as below:

<
telerik:RadGrid ID="rgSchool" ShowGroupPanel="false" ShowStatusBar="true" AllowCustomPaging="true"

            RegisterWithScriptManager="true" runat="server" AutoGenerateColumns="False" AllowSorting="True"

            GridLines="Vertical" OnSortCommand=" rgSchool _SortCommand" AllowMultiRowSelection="False"

            AllowPaging="True" Skin="Vista" OnNeedDataSource=" rgSchool _NeedDataSource"

            OnPageIndexChanged=" rgSchool _PageIndexChanged" OnPageSizeChanged=" rgSchool _PageSizeChanged"

            OnItemDataBound=" rgSchool _ItemDataBound" OnGroupsChanging=" rgSchool _GroupChanging"

            OnColumnHiding=" rgSchool _ColumnHidden">

            <SortingSettings EnableSkinSortStyles="false" />

            <PagerStyle Mode="NextPrevNumericAndAdvanced" AlwaysVisible="true"></PagerStyle>

            <MasterTableView Width="100%" DataKeyNames="SerialNumber, StudId,Status" ClientDataKeyNames="SerialNumber, StudId,Status"

                AllowMultiColumnSorting="false" EnableHeaderContextMenu="true" AutoGenerateColumns="false"

                TableLayout="auto">

                <Columns>

 

                    <telerik:GridBoundColumn DataField="DateJoin" HeaderText="Date Of Joining" SortExpression="DateReceived"

                        Visible="true" DataFormatString="{0:MM/dd/yyyy}" />

                    <telerik:GridBoundColumn DataField="SerialNumber" HeaderText="Serial #" SortExpression="SerialNumber"

                        Visible="true" DataFormatString="{0:N0}" />

                    <telerik:GridBoundColumn DataField=" StudId " HeaderText="Student ID #" SortExpression=" StudId "

                        Visible="true" />

                    <telerik:GridBoundColumn DataField="Status" HeaderText="Status" SortExpression="Status"

                        Visible="true" />

                    </telerik:GridBoundColumn>

                </Columns>

            </MasterTableView>

            <ClientSettings AllowColumnsReorder="true" ReorderColumnsOnClient="true" EnableRowHoverStyle="true">

                <Scrolling AllowScroll="false" SaveScrollPosition="true" UseStaticHeaders="true" />

                <Resizing AllowColumnResize="true" EnableRealTimeResize="false" ResizeGridOnColumnResize="false"

                    ClipCellContentOnResize="false" AllowResizeToFit="true" />

                <Selecting AllowRowSelect="true" />

                <ClientEvents OnRowDblClick="RowDblClick" OnRowSelected="RowSelected" OnRowContextMenu="onRowContextMenu"

                    OnColumnHidden=" rgSchoolColumnHidden" OnColumnShown=" rgSchoolColumnShown" />

            </ClientSettings>

            <HeaderContextMenu EnableScreenBoundaryDetection="true" EnableAutoScroll="true" />

        </telerik:RadGrid>

So,the users can sort,Hide,Group the columns.The sorting of the column will be done in the SP itself,based on the column(header selected).So,From the SP though get the correctly sorted data(i.e., though the DataSource is updated correctly),the grid is not STILL NOT showing the correctly sorted data.Please find the related server side code below :

protected void rgSchool_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)

{

try

{

ViewState["CurrentPageIndex"] = rgSchool.CurrentPageIndex + 1;

 //Getting the sorted,......data through SP.and storing in response object.

  IEnumerable<rgSchoolReadRecord> response = WCFObj.Read(out recordCount, request);

rgSchool.DataSource = null;

rgSchool.DataSource = response;//DataSorce is updating correctly

rgSchool.VirtualItemCount = recordCount;

rgSchool.CurrentPageIndex = request.PageIndex - 1;

WCFObj.Close();

//Set the current paging and sorting in View state

ViewState["CurrentPageIndex"] = request.PageIndex;

ViewState["PageSize"] = request.PageSize;

ViewState["CurrentSort"] = request.OrderBy;

ViewState["SortDescending"] = request.Desc;

ViewState["rgSchoolSearchRequestObjet"] = request;

ViewState["recordCount"] = recordCount;

}}

1 Answer, 1 is accepted

Sort by
0
Antonio Stoilkov
Telerik team
answered on 30 Nov 2011, 12:07 PM
Hello Dilip,




I tried to reproduce the issue locally, but without success. Based on your code, I built a sample project that works as expected on my side. However you could try setting the RadGrid DataSource property to null before calling the Rebind method and see if it helps in your case.

Please let me know if the proposed solution helps.

Greetings,
Antonio Stoilkov
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
Tags
Grid
Asked by
Dilip
Top achievements
Rank 1
Answers by
Antonio Stoilkov
Telerik team
Share this question
or