Hi All,
I have a radGrid in a radTabStrip that has paging enabled like so:
In the code behind I have this:
This whole thing kind of works. I can't use .Bind() or .Rebind() because of the implicit binding that happens with this event. However, the paging doesn't work all that great. If I page to the last page the final two records are displayed. If I change tabs (yes in a tab strip) I manually call the NeedDataSource(null, null) to get the dataset to change from 'Unassigned' to some other filtered value of the data. The problem is that the old data that was on the grid + the new data shows up! What the heck? What I could use right now is a way to clear this grid of it's contents and bind it to a new list. Where is the .ClearGridContents() method I so desire right now? Maybe a grid.Refresh thrown in for good measure.
So, long story short. How do I clear this darn grid and have it auto-bind (like i have a choice), with a fresh set of data that is artifact free?
Thanks,
Felix
BTW, I'm using OpenAccess which I find very easy to use.
I have a radGrid in a radTabStrip that has paging enabled like so:
</telerik:RadTabStrip> <telerik:RadGrid ID="gridWORKORDERS" runat="server" OnRowDrop="gridWORKORDERS_RowDrop" Height="400px" AllowMultiRowSelection="false" EnableHeaderContextMenu="false" Width="444px" HorizontalAlign="Center" OnItemCommand="radgridWORKORDERS_ItemCommand" OnNeedDataSource="gridWORKORDERS_NeedDataSource"> <MasterTableView DataKeyNames="pm_strWorkOrderID" Width="444px" HorizontalAlign="Center" TableLayout="Fixed" ClientDataKeyNames="pm_strWorkOrderID" AllowPaging="True" AllowCustomPaging="true" AutoGenerateColumns="false">... etc.In the code behind I have this:
protected void gridWORKORDERS_NeedDataSource(object source, GridNeedDataSourceEventArgs e){ int recordCount = 0; List<WorkOrderEx> workOrders = new List<WorkOrderEx>(); string sessionTab = Session[_WO_FILTER_TAB] == null ? "Unassigned" : Session[_WO_FILTER_TAB].ToString(); gridWORKORDERS.DataSource = null; switch (sessionTab) { case "Unassigned": // Need to do this in a couple of steps or the grid paging doesn't work properly recordCount = DbContext.WorkOrders.Where(f => f.AssignedTechs.Count <= 0).Count(); // Save ourselves some time.. if (recordCount > 0) workOrders = DbContext.WorkOrders.Where(f => f.AssignedTechs.Count <= 0) .OrderBy(x => x.WorkOrderId) .Skip(gridWORKORDERS.PageSize * gridWORKORDERS.CurrentPageIndex) .Take(gridWORKORDERS.PageSize) .Select(k => new WorkOrderEx(DbContext, k)).ToList(); break; case "blah blah blah.. Looks very much like the first case statement.": break; } gridWORKORDERS.VirtualItemCount = recordCount; gridWORKORDERS.DataSource = workOrders; //gridWORKORDERS.Rebind(); <-- Enabling this blows everything up.. You know what I mean. :)}This whole thing kind of works. I can't use .Bind() or .Rebind() because of the implicit binding that happens with this event. However, the paging doesn't work all that great. If I page to the last page the final two records are displayed. If I change tabs (yes in a tab strip) I manually call the NeedDataSource(null, null) to get the dataset to change from 'Unassigned' to some other filtered value of the data. The problem is that the old data that was on the grid + the new data shows up! What the heck? What I could use right now is a way to clear this grid of it's contents and bind it to a new list. Where is the .ClearGridContents() method I so desire right now? Maybe a grid.Refresh thrown in for good measure.
So, long story short. How do I clear this darn grid and have it auto-bind (like i have a choice), with a fresh set of data that is artifact free?
Thanks,
Felix
BTW, I'm using OpenAccess which I find very easy to use.