hey
im using advanced databinding with data from sql db.
so i have this code that when a column (files recieved) is sorted, i highlight rows that a month has passed since the since it was created, files were received but still it was not processed (to alert users). I had the idea i will add an unbound column, and assign it a priority number for the rows that are highlighted. There will be different priority for different "rules", so i could have some rows highlighted red with priority 1, while some are yellow with priority 2. now when this happens i want to create a default sort, before any other sorts are applied, that the rows with highest priority will show up first.
so thats the jist of what im trying to do. i know the regular sort wont work because the item is not bound, so its not a dataitem. what i tried to do was on the onneeddatasource event, after i have my datatable, i apply the sort by priority on the dataview of the datatable (the datatable does have the column with priority with the proper values). This seems to work as the datatable i assign as the datasource for the grid does show up in the exact order it should, priority items first. But i see that the other sort expressions of other columns are not yet applied, this leads me to believe that the datasource gets sorted after the event, overwriting the manual sort i applied.
is there an event i should override where i can plug in my manual sort? or maybe someone has a better idea how to implement the functionality im looking to achieve? here is the relevant code:
protected void rgListingsReport_NeedDataSource(object source, GridNeedDataSourceEventArgs e) {if ((HttpContext.Current.Cache["data"] == null ) {// gets datatable from sql} else { _dtReportsSource = (DataTable)HttpContext.Current.Cache["data"]; } if (_dtReportsSource != null) { if (doSort) //true when there are rows with priority { _dtReportsSource.DefaultView.Sort = "NoticePriority DESC"; _dtReportsSource = _dtReportsSource.DefaultView.ToTable(); rgListingsReport.DataSource = _dtReportsSource; } else { rgListingsReport.DataSource = _dtReportsSource; } }}on the item databound event i set the priority values for the rows and datatable stored in cache
if (rowColor == Color.Red) { dataBoundItem["NoticePriority"].Text = "1"; (HttpContext.Current.Cache["data"] as DataTable).Rows[e.Item.RowIndex]["NoticePriority"] = "1"; } else { dataBoundItem["rowindex"].Text = "0"; dataBoundItem["NoticePriority"].Text = "0"; }