I'm experiencing a bizarre issue with RadGridView.
I had a grid on a form that displays the results of a List collection. Pretty simple, but there was one column that refused to display the data. The column itself appeared but the data didn't display. I moved everything to another form and it worked fine.
Now I added another column to the grid and now that won't display data. The data is in the list collection, the FieldName property is correct (I even copied it from the POCO to make sure.). Then I added another column to the grid and it won't display at all at runtime even though it shows in the designer. Here is the code from the designer:
Any ideas on this one. I've never had a grid act like this before. Unfortunately I can't send you demo code s if I copy it to another form it will work.
Carl
gvMemos.MasterTemplate.AllowAddNewRow = false;gvMemos.MasterTemplate.AllowColumnHeaderContextMenu = false;
gvMemos.MasterTemplate.AllowDeleteRow = false;
gvMemos.MasterTemplate.AllowEditRow = false;
gvMemos.MasterTemplate.AllowRowHeaderContextMenu = false;
gvMemos.MasterTemplate.AllowRowResize = false;
gvMemos.MasterTemplate.AllowSearchRow = true;
gvMemos.MasterTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
gridViewTextBoxColumn1.EnableExpressionEditor = false;
gridViewTextBoxColumn1.FieldName = "MemoOptionsDescription";
gridViewTextBoxColumn1.HeaderText = "column1";
gridViewTextBoxColumn1.Name = "column1";
gridViewTextBoxColumn1.ReadOnly = true;
gridViewTextBoxColumn1.Width = 284;
gridViewTextBoxColumn2.DataType = typeof(DateTime);
gridViewTextBoxColumn2.EnableExpressionEditor = false;
gridViewTextBoxColumn2.FieldName = "DateTimeStamp";
gridViewTextBoxColumn2.HeaderText = "Date/Time";
gridViewTextBoxColumn2.Name = "Date";
gridViewTextBoxColumn2.Width = 284;
gridViewTextBoxColumn3.EnableExpressionEditor = false;
gridViewTextBoxColumn3.FieldName = "MemoText2";
gridViewTextBoxColumn3.HeaderText = "Memo Description";
gridViewTextBoxColumn3.Name = "Memo Description";
gridViewTextBoxColumn3.ReadOnly = true;
gridViewTextBoxColumn3.Width = 284;
gridViewTextBoxColumn4.EnableExpressionEditor = false;
gridViewTextBoxColumn4.FieldName = "AssignedTo";
gridViewTextBoxColumn4.HeaderText = "Assigned To";
gridViewTextBoxColumn4.Name = "Assigned To";
gridViewTextBoxColumn4.ReadOnly = true;
gridViewTextBoxColumn4.Width = 284;
gridViewTextBoxColumn5.FieldName = "MemoTypeDescription";
gridViewTextBoxColumn5.HeaderText = "Type";
gridViewTextBoxColumn5.Name = "Memo Type";
gridViewTextBoxColumn5.Width = 284;
gridViewTextBoxColumn6.EnableExpressionEditor = false;
gridViewTextBoxColumn6.FieldName = "MemoOptionsDescription";
gridViewTextBoxColumn6.HeaderText = "Options";
gridViewTextBoxColumn6.Name = "Options";
gridViewTextBoxColumn6.ReadOnly = true;
gridViewTextBoxColumn6.Width = 284;
gridViewTextBoxColumn7.EnableExpressionEditor = false;
gridViewTextBoxColumn7.FieldName = "OperID";
gridViewTextBoxColumn7.HeaderText = "User";
gridViewTextBoxColumn7.Name = "User";
gridViewTextBoxColumn7.ReadOnly = true;
gridViewTextBoxColumn7.Width = 282;
gvMemos.MasterTemplate.Columns.AddRange(new Telerik.WinControls.UI.GridViewDataColumn[] { gridViewTextBoxColumn1, gridViewTextBoxColumn2, gridViewTextBoxColumn3, gridViewTextBoxColumn4, gridViewTextBoxColumn5, gridViewTextBoxColumn6, gridViewTextBoxColumn7 });
gvMemos.MasterTemplate.EnableAlternatingRowColor = true;
gvMemos.MasterTemplate.EnablePaging = true;
gvMemos.MasterTemplate.ShowGroupedColumns = true;
gvMemos.MasterTemplate.ViewDefinition = tableViewDefinition1;
gvMemos.Name = "gvMemos";
gvMemos.Size = new System.Drawing.Size(1767, 229);
gvMemos.TabIndex = 4;
gvMemos.CellFormatting += OnCellFormattingMemos;
gvMemos.ViewCellFormatting += OnViewCellFormattingMemos;
gvMemos.ContextMenuOpening += OnContextMenuOpeningMemos;
gvMemos.DoubleClick += gvMemos_DoubleClick;
Hi Carl. Given your description, I can only speculate and I certainly understand about how some of us cannot share our code publicly so if I'm way off the mark, please forgive the intrusion!
You should be able to easily determine that 1) You have Rows. 2) You have the Column you cannot see:
given: myRow is Type GridViewRowInfo
If myRow.Cells("column name") IsNot Nothing then... and verify there IS data in the cell: If myRow.Cells("column name").Value IsNot Nothing then...
If you confirmed the above then, is it visible? If myGrid.Columns("column name").IsVisible = True
And lastly if IsVisible=True, i'd want to know if the Column has Width? If myGrid.Columns("column name").Width > 0 make sure it's a LOT greater than 0! If its 1 pixel wide, it'll just look like a Column separator.
If all of the above passes - has it been scrolled off the screen? Check the index and check the index of the last column you see. If you're > than that last one, you're scrolled out.
Nothing I've written will be a surprise to any of us but it's nice to have a list to work off - for me anyway! Ok so all of the above look good - the last thing I'd be looking at would be special rendering. Are you using HTML strings? Formatting? Conditional Formatting? Anything that's out of whack in any of those, could cause nothing to show up in the cell.
I know, grasping at straws. I just hope maybe something in my rant will lend to a light-bulb moment! Good luck!
-LK
Hi Carl,
Thank you for reaching out to us.
Without being able to isolate this behavior, I can only guess what the exact reason might be. I understand that isolating a specific behavior is time-consuming and not a straightforward process when extracting code from a large application. Nevertheless, I could share some steps to investigate this further.
Curtis described a good starting point to investigate this behavior. If only one column is not displaying the data, you can try removing all other columns from the grid and leaving only the one that does not have data. This way, we can see if the other columns are not affecting this one.
Then you can check if you have a custom code that targets the cells in some way. Do you have a custom cell that is applied to that column? You can also mention which column from the shared code snippet is not working as expected.
Another thing that comes to my mind is subscribing to the CellFormatting event, which will be called only for data cells. In the event handler, you can check the data cell's Value and Text properties to see if they contain a value.
Many thanks for both responses. We solved the problem by moving all the code to a new form. I will bookmark this page and include the link in the code comments in case it happens again.
Thanks
Carl