We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Binding to sql_variant type not working

Thread ID:





44371 May 22,2006 07:26 PM Jun 2,2006 02:13 AM Windows Forms 7
Tags: Grouping
Martin Nitschke
Asked On May 22, 2006 07:26 PM

I have a GridGroupingControl bound to a DataTable. The DataTable is created by using a view in the SQL Server database. One DataColumn is of datatype System.Object, which I guess is what the is created when my database table is of sql_variant type. The problem is when I go to update the field in the GroupingGrid. It blanks out my value when I tab or move to a new cell. The value it puts in the Record is DBNull. I put an AllowDBNull = false on my datacolumn and I received a messagebox with an errorprovider in my column that said SaveRecord: column does not allow nulls when I tried to change the record. I was trying to figure out where an exception might be thrown, and I guess it is thrown within the GroupingGridControl. In order to determine if it was indeed the sql_variant type, I changed the column to numeric and I was able to update the column in the grouping grid without a problem.

Administrator [Syncfusion]
Replied On May 23, 2006 02:49 AM

Hi Martin, Could try this code to resolve this issue. Here is a code snippet. //Form Load event. GridTextBoxCellRenderer cr = this.gridGroupingControl1.TableControl.CellRenderers["TextBox"] as GridTextBoxCellRenderer; if(cr != null) { cr.TextBox.TextChanged +=new EventHandler(TextBox_TextChanged); } private void TextBox_TextChanged(object sender, EventArgs e) { GridOriginalTextBoxControl t = sender as GridOriginalTextBoxControl; GridCurrentCell cc = this.gridGroupingControl1.TableControl.CurrentCell; if(cc.ColIndex == 2) { cc.Renderer.ControlValue = (object)t.Text; //cc.ConfirmChanges(true); //If it is not working, you can use this confirmChanges(). } } Please let me know if this helps. Best Regards, Haneef

Martin Nitschke
Replied On May 23, 2006 02:50 PM

It works, except for one problem. I do not know the column index, but I know the column header. How can I find the value of the column header?

Martin Nitschke
Replied On May 23, 2006 03:48 PM

I found it. This does not work: //cc.ConfirmChanges(true); //If it is not working, you can use this confirmChanges(). here is the code to get the header text: GridTableDescriptor gtd = stationTable.TableControl.TableDescriptor; string columnName = gtd.VisibleColumns[cc.ColIndex - 1].GetName();

Martin Nitschke
Replied On May 26, 2006 03:53 PM

I have another problem. The Text_Changed event does not fire if I currently have a value the same number or characters long when I hit the down arrow. For example, I have values of all 2''s in my column. I click the first one, press 3, then the down arrow. As I continue entering 3 and pressing the down arrow the text_changed never fires. however, if I were to replace a 2 with 33, since the length changed, it does fire.

Administrator [Syncfusion]
Replied On May 29, 2006 12:40 AM

Hi Martin, Sorry for the inconvenience caused. I have tested this issue by creating a sample in v. and then again tested by upgrading to V4.2. I was not able to reproduce the issue.Maybe I am not following the steps that you are doing. Attached sample working fine here. If you can send us a sample that does not work, we can try to debug it here. Here is a sample. http://www.syncfusion.com/Support/user/uploads/SQL_Varient_dd51d03e.zip Could you please run this at your end and let me know how it goes? Thanks for your co-operation. Regards, Haneef Note: Before run the sample, you need to change the connection string and create a table with two column.

Martin Nitschke
Replied On May 30, 2006 01:53 PM

I ran the test on my end. I have the .63 version. I created a table in the NW database. I inserted row1, 1; row2, 2; row3, 3; etc for data values. In order to reproduce the error. Click into the first column with the value row1. Press the tab key. You will move to column 2, where the current value is 1. Without doing anything else, type in the value 2, then press the down arrow key. No text changed event is written to the console (per your code) and the value of the cell is blank. You can continue typing in single values and the same result will be for all the columns. However, if you were to type in 33 or 44, the Text Changed event would fire and write to the Console.

Administrator [Syncfusion]
Replied On June 2, 2006 02:13 AM

Hi Martin, I regret really for the inconvenience caused. I was able to see the mentioned issue here. I have tested the modified sample in 4.1 and then again tested by upgrading to 4.2 which is working fine. Please find the modified code/sample below. private void gridGroupingControl1_TableControlCurrentCellChanged(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlEventArgs e) { CovertCellValueToObject(); } public void CovertCellValueToObject() { GridCurrentCell cc = this.gridGroupingControl1.TableControl.CurrentCell; GridTextBoxCellRenderer cr = cc.Renderer as GridTextBoxCellRenderer; GridOriginalTextBoxControl t = cr.TextBox as GridOriginalTextBoxControl; if(cc.ColIndex == 2) { cc.Renderer.ControlValue = (object)t.Text; cc.ConfirmChanges(true); } Console.WriteLine("Fire"); } private void gridGroupingControl1_TableControlCurrentCellMoving(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCurrentCellMovingEventArgs e) { GridCurrentCell cc = this.gridGroupingControl1.TableControl.CurrentCell; if(cc.MoveFromColIndex == 2) { CovertCellValueToObject(); } } Here is a modified sample. http://www.syncfusion.com/Support/user/uploads/SQL_Varient_c7306398.zip Please let me know if this helps. Regards, Haneef


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon