or

</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.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. :)}protected void Page_Load(object sender, EventArgs e) { if (Session["GridData"] == null) { DataTable table = GetTable(); Session.Add("GridData", table); } DefineGridStructure(); } private void DefineGridStructure() { RadGrid grid = new RadGrid(); grid.ID = "RadGrid1"; grid.NeedDataSource += new GridNeedDataSourceEventHandler(grid_NeedDataSource); grid.AutoGenerateEditColumn = true; grid.AutoGenerateDeleteColumn = true; grid.AllowAutomaticInserts = true; grid.Width = Unit.Percentage(100); grid.PageSize = 15; grid.AllowPaging = true; grid.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric; grid.AutoGenerateColumns = false; grid.MasterTableView.Width = Unit.Percentage(100); grid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.TopAndBottom; grid.AllowAutomaticDeletes = true; grid.AllowAutomaticUpdates = true; grid.InsertCommand +=grid_InsertCommand; grid.MasterTableView.DataKeyNames = new string[] { "RowNumber" }; GridBoundColumn boundColumn = new GridBoundColumn(); boundColumn.DataField = "RowNumber"; boundColumn.HeaderText = "RowNumber"; boundColumn.ReadOnly = true; grid.MasterTableView.Columns.Add(boundColumn); boundColumn = new GridBoundColumn(); boundColumn.DataField = "Size"; boundColumn.HeaderText = "Size"; grid.MasterTableView.Columns.Add(boundColumn); boundColumn = new GridBoundColumn(); boundColumn.DataField = "Description"; boundColumn.HeaderText = "Description"; grid.MasterTableView.Columns.Add(boundColumn); boundColumn = new GridBoundColumn(); boundColumn.DataField = "Quantity"; boundColumn.HeaderText = "Quantity"; grid.MasterTableView.Columns.Add(boundColumn); boundColumn = new GridBoundColumn(); boundColumn.DataField = "Duration"; boundColumn.HeaderText = "Duration"; grid.MasterTableView.Columns.Add(boundColumn); boundColumn = new GridBoundColumn(); boundColumn.DataField = "DurationType"; boundColumn.HeaderText = "DurationType"; grid.MasterTableView.Columns.Add(boundColumn); boundColumn = new GridBoundColumn(); boundColumn.DataField = "Amount"; boundColumn.HeaderText = "Amount"; grid.MasterTableView.Columns.Add(boundColumn); PlaceHolder1.Controls.Add(grid); } private void grid_InsertCommand(object sender, GridCommandEventArgs e) { // Looking to loop through the form so i can insert the values into the datatable } void grid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { DataTable current = (DataTable)Session["GridData"]; RadGrid grid = (RadGrid)sender; grid.DataSource = current; } static DataTable GetTable() { // // Here we create a DataTable with a few columns. // // Create Datatable to store all colums DataTable dt = new DataTable(); DataRow dr = null; dt.Columns.Add(new DataColumn("RowNumber", typeof(string))); dt.Columns.Add(new DataColumn("Size", typeof(string))); dt.Columns.Add(new DataColumn("Description", typeof(string))); dt.Columns.Add(new DataColumn("Quantity", typeof(string))); dt.Columns.Add(new DataColumn("Unit", typeof(string))); dt.Columns.Add(new DataColumn("Duration", typeof(string))); dt.Columns.Add(new DataColumn("DurationType", typeof(string))); dt.Columns.Add(new DataColumn("Amount", typeof(string))); dr = dt.NewRow(); dr["RowNumber"] = 1; dr["Size"] = string.Empty; dr["Description"] = string.Empty; dr["Quantity"] = string.Empty; dr["Unit"] = string.Empty; dr["Duration"] = string.Empty; dr["DurationType"] = string.Empty; dr["Amount"] = string.Empty; dt.Rows.Add(dr); return dt; }