I have a radgridview with 3 columns, one of which is a gridviewlookupcolumn.
The data is populated using LinqToSql classes as followingf
DataClasses2DataContext
dcl = new DataClasses2DataContext();
GridViewLookUpColumn gvc = new GridViewLookUpColumn("SuitabilityIndex1");
radGridView1.DataSource = dcl.USBDevices;
radGridView1.Columns[
"Id"].IsVisible = false;
radGridView1.Columns[
"SuitabilityIndex"].IsVisible = false;
radGridView1.Columns[
"Manufacturer"].StretchVertically = true;
System.Collections.Generic.
List<short> dd = new List<short>();
dd.Add(0);
dd.Add(1);
dd.Add(2);
gvc.DataSource = dd;
radGridView1.Columns.Add(gvc);
radGridView1.Columns[
"SuitabilityIndex1"].FieldName = "SuitabilityIndex";
The field SuitabilityIndex in the database is smallInt that allows null. The datasource for the lookup column is short
When I change the value in the lookup column, it fires the data error event with the following error
{Telerik.WinControls.UI.GridViewDataErrorEventArgs}
base {Telerik.WinControls.UI.GridViewCellCancelEventArgs}: {Telerik.WinControls.UI.GridViewDataErrorEventArgs}
Context: Commit
Exception: {"Object of type 'System.String' cannot be converted to type 'System.Nullable`1[System.Int16]'."}
ThrowException: false
I think the problem is that the lookupcolumn thinks that the datatype os string. I can say that for sure since the allignmnet of values on the grid are to the left and not to the right.
I tried setting the datatype of the column to short, but did not help
Thanks
Deepak
| RadGridView gridView = new RadGridView(); |
| gridView.Name = name; |
| gridView.Anchor = (System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right); |
| gridView.AutoSize = true; |
| gridView.AutoScroll = true; |
| gridView.MasterGridViewTemplate.BestFitColumns(); |
| //gridView.MasterGridViewTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; |
| gridView.MasterGridViewTemplate.AutoGenerateColumns = false; |
| gridView.MasterGridViewTemplate.AllowAddNewRow = true; |
| gridView.ShowGroupPanel = false; |
| gridView.ContextMenuOpening += new ContextMenuOpeningEventHandler(gridView_ContextMenuOpening); |
| gridView.GridBehavior = new MyBehavior(); // see behavior below |
| gridView.CellBeginEdit += new GridViewCellCancelEventHandler(gridView_CellBeginEdit); |
| gridView.CellValueChanged += new GridViewCellEventHandler(gridView_CellValueChanged); |
| gridView.StandardTab = true; |
Hi,
We have a problem with the rendering of the grid(version 2009.3.9.1203) since we upgrade to version 2009 Q3.
He is the code we use to set the columns width :
Me.Instance.DataSource = Value
Me.Instance.GridElement.BeginUpdate()
If Me.Instance.MasterGridViewTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None Then
For Each column As GridViewDataColumn In Me.Instance.Columns
column.BestFit()
Next
End If
Me.Instance.GridElement.EndUpdate()
Since we update, the column.BestFit() don't work and all column have like width of 1...? We usually have grid with more than 10 columns and it has always work fine.
What should we do to fix it?
thx