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

Sorting with SQLDataSource vs LinqDataSource

1 Answer 127 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 17 Oct 2014, 12:45 AM
Hi,

I have run into a bit of a problem with Sorting my grid and it seems to be related to the datasource, but I can't see why.

Originally in the code behind I had in the NeedDatasource event for my grid:
Dim lnqMerchSellers = db.usp_MER_Sellers_GetAll(drpStatus.SelectedValue, iSelectedCountryGroup, PageHelper.getUserAccessLevel(Profile.License, HttpContext.Current.User.Identity.Name, "Merchandise").ToString())
rgdMerchSellerList.DataSource = lnqMerchSellers

Sorting works.

I've now removed the sproc (usp_MER_Sellers_GetAll) from my DAL and access it using a SQL Datasource object on my aspx page.
<asp:SqlDataSource ID="sqlUserList" runat="server" ConnectionString="<%$ ConnectionStrings:AU_Deals_ConnectionString %>" SelectCommand="usp_MER_Sellers_GetAll" SelectCommandType="StoredProcedure" />

Then in the codebehind's NeedDatasource for my grid I use:
sqlUserList.SelectParameters.Clear()
sqlUserList.SelectParameters.Add("filter", DbType.Int32, drpStatus.SelectedValue)
sqlUserList.SelectParameters.Add("countryGroupID", DbType.Int32, iSelectedCountryGroup.ToString())
sqlUserList.SelectParameters.Add("accessLevel", DbType.String, PageHelper.getUserAccessLevel(Profile.License, HttpContext.Current.User.Identity.Name, "Merchandise").ToString())
 
rgdMerchSellerList.DataSource = lnqMerchSellers

Sorting on my grid, now doesn't work and I don't see why.

Any help would be greatly appreciated.

Thanks.

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 21 Oct 2014, 04:01 PM
Hello Adam,

Generally, if you are providing an object as a data source to the grid within the OnNeedDataSource event, RadGrid will use its sorting mechanism on that object (DataTable, DataSet or any object collection that implements the IListSource, IList, IEnumerable, or ICustomTypeDescriptor interface), depending on the users interaction.

Since you are setting the DataSource property manually in both examples, I am not sure how the sorting will work in one of them. Can you please provide the markup of your RadGrid, so we can have a better idea of your exact scenario and made some test locally based on that?


Kind Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Adam
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or