Hi
I got a problem with a dynamically created RadGrid.
My definition is the following:
As you can see the grid performs a PostBack on click on a row. So if the grid or another control on the page performs a PostBack the grid gets some new, completly empty columns. They are exactly as many as the defined ones (in our case 2).
Did I miss anything? What am I doing wrong?
Best regards
Ferdinand
I got a problem with a dynamically created RadGrid.
My definition is the following:
| protected void Page_Init(object sender, EventArgs e) |
| { |
| createGrid("rgSchedules", "TK_ID", true, this.phSchedulesGrid, out this.rgSchedules); |
| createSchedulesGridColumns(this.rgSchedules); |
| this.rgSchedules.SelectedIndexChanged += new EventHandler(rgSchedules_SelectedIndexChanged); |
| } |
| void rgSchedules_SelectedIndexChanged(object sender, EventArgs e) |
| { |
| // nothing happens but PostBack for test purposes |
| } |
| private void createGrid(string gridId, string datakeyName, bool autoPostBack, PlaceHolder ph, out RadGrid localGrid) |
| { |
| RadGrid grid = new RadGrid(); |
| grid.DataSourceID = "odsSchedules"; |
| grid.EnableViewState = false; |
| grid.ID = gridId; |
| grid.BorderStyle = BorderStyle.None; |
| grid.AutoGenerateColumns = false; |
| grid.AllowSorting = true; |
| grid.AllowPaging = false; |
| grid.AllowMultiRowSelection = false; |
| grid.Height = 450; |
| grid.Width = 450; |
| grid.GridLines = GridLines.None; |
| grid.PagerStyle.Visible = false; |
| grid.ClientSettings.EnablePostBackOnRowClick = autoPostBack; |
| grid.ClientSettings.EnableRowHoverStyle = true; |
| grid.ClientSettings.Selecting.AllowRowSelect = true; |
| grid.ClientSettings.Scrolling.AllowScroll = true; |
| grid.ClientSettings.Scrolling.UseStaticHeaders = true; |
| grid.ClientSettings.Scrolling.SaveScrollPosition = true; |
| grid.ClientSettings.Resizing.AllowColumnResize = true; |
| grid.ClientSettings.Resizing.ClipCellContentOnResize = false; |
| grid.ClientSettings.Resizing.EnableRealTimeResize = true; |
| grid.ClientSettings.Resizing.ResizeGridOnColumnResize = true; |
| grid.MasterTableView.DataKeyNames = new string[] { datakeyName }; |
| grid.MasterTableView.OverrideDataSourceControlSorting = true; |
| localGrid = grid; |
| ph.Controls.Clear(); |
| ph.Controls.Add(grid); |
| } |
| private void createSchedulesGridColumns(RadGrid grid) |
| { |
| grid.Columns.Clear(); |
| string nameCaption = this.GetLocalResourceObject("appointment").ToString(); |
| DynamicGrid.AddBoundFieldToGridView("TK_BEZEICHNUNG", nameCaption, grid); |
| DynamicGrid.AddDateTimeFieldToGridView("TK_ANFANG", this.GetLocalResourceObject("begin").ToString(), |
| grid); |
| } |
As you can see the grid performs a PostBack on click on a row. So if the grid or another control on the page performs a PostBack the grid gets some new, completly empty columns. They are exactly as many as the defined ones (in our case 2).
Did I miss anything? What am I doing wrong?
Best regards
Ferdinand