I have Column which have data like digits and string together . But I need this to be sorted by digits. Once Click on column sorting the data From stored procedure is getting sorted as required. But after binding to grid the data in the column changes. Please help
Below is the column data
Hello ramya y,
Thank your for contacting us.
About your question, when data is formed by digits and strings together it is considered as a string only, you cannot sort it by digits.
Could I ask you what do you mean by saying "data in the column changes" do you mean that the data is lost? How you are binding your grid? If you set the data source through the code behind on Page_Load for example, you should provide this data source every time on postback. Could you please share with me isolated sample that is showing the issue, in order to investigate this behavior.
When sorting is used, and you rebind the grid after some column was already sorted, the order should be persisted.
Looking forward to hearing from you.
Hi Zdravko Kolev ,
Thanks for the response. Actually I am binding the data in server side. When I click on the column for sorting. The Stored procedure takes care of the sorting and provided the sorted values. The Sorting for the mentioned column(Total Budget) is perfect from stored procedure. But after binding that to Grid the order changes.
This is the code where I am binding the data to grid :
{
dgBudgetApprovalAlerts.DataSource = m_ResultDataSet;
dgBudgetApprovalAlerts.DataBind();
Enter.Visible = true;
Pager1.Visible = true;
dgBudgetApprovalAlerts.Visible = true;
NoRecords.InnerHtml = "";
}
The dataset from Stored procedure where TotalBudget is Sorted in ASC.
But after binding to grid the result is . We need grid to display data as it is in Dataset.
Hello,
Could you please share a small sample with me that is showing this issue in order to investigate it further for you.
Looking forward for your reply.
Hi Zdravko,
For example . Once I click the column on the grid for sorting the data in the TotalBudget fetching from Database by Stored procedure looks like :
TotalBudget
$22.00
$100.00
$354.00
$370.00
$2000.00
$15000.00 * 2 Activities
$20000.00
But When it binds to the grid the valuw displayed in the grid looks like
Hope this explains the issue . Please let me know for any queries.
Could you please try to reproduce this issue in a separate sample in order to investigate it further for you.
Hi,
I have added the code suggested . I removed sorting then binded the data. But still IgGird doing it own sorting. Please check the below code
protected void dgBudgetApprovalAlerts_SortColumn(object sender, Infragistics.Web.UI.GridControls.SortingEventArgs e) { e.SortedColumns.Clear(); e.SortedColumns.Remove(e.SortedColumns[e.Column.Key]); string strOrder = string.Empty; if (PWWebHelper.GetWebSafeInt(CurrPageIndex.InnerText) == e.Column.Index) { if (PWWebHelper.GetWebSafeTrimmedString(hdnDBSortOrder.InnerText) == "ASC") strOrder = "DESC"; else strOrder = "ASC"; } else strOrder = "ASC"; for (int index = 0; index < dgBudgetApprovalAlerts.Behaviors.Sorting.SortedColumns.Count - 1; index++) { dgBudgetApprovalAlerts.Behaviors.Sorting.SortedColumns.Add(dgBudgetApprovalAlerts.Columns[e.Column.Index], Infragistics.Web.UI.SortDirection.None); }
if (strOrder == "ASC") { dgBudgetApprovalAlerts.Behaviors.Sorting.SortedColumns.Add(dgBudgetApprovalAlerts.Columns[e.Column.Index], Infragistics.Web.UI.SortDirection.Ascending); } else { dgBudgetApprovalAlerts.Behaviors.Sorting.SortedColumns.Add(dgBudgetApprovalAlerts.Columns[e.Column.Index], Infragistics.Web.UI.SortDirection.Descending); }
//hdnSortColumnNo.InnerText = e.Column.Index.ToString(); hdnSortColumn.InnerText = dgBudgetApprovalAlerts.Columns[e.Column.Index].Key; CurrPageIndex.InnerText = PWWebHelper.GetWebSafeTrimmedString(e.Column.Index); hdnDBSortOrder.InnerText = strOrder; BindData(m_SupplierKey); HighLightColumn(sender, e.Column.Index, hdnDBSortOrder.InnerText); }
Thank you for the detailed explanation. The reason our Grid to behave like that is because these values are considered as strings and the Grid sort them like strings, not integers. Possible solution would be to clear the sorted column and then do bind the customly sorted data, the Grid will not try to resort it by its string value.
For more information you can have a look at this forum thread where my colleague Michael explain in details this approach:
http://ko.infragistics.com/community/forums/t/80117.aspx
Related reference:
http://ko.infragistics.com/community/forums/t/83579.aspx