This is a migrated thread and some comments may be shown as answers.

Binded check box column data type issue

5 Answers 45 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chandra Sekhar
Top achievements
Rank 1
Chandra Sekhar asked on 30 Sep 2016, 07:49 PM

Hi,

I m new to using Telerik controls and working on using a radgridview in my project. I have to bind a string DB column(Y/N) to a check box column in the grid and when user changes the check boxes, appropriate check box state has to be converted as Y/N and save back to the business entity object which was bonded. I have used the type converters to convert the TRUE/FALSE values to Y/N, but for some reason, they are again becoming as TRUE/FALSE before committing the dataset. Can anyone throw some light on whats happening here?

Also not sure about which event to handle when user changes the check boxes and appropriately change corresponding Be updated. Thanks much in advance.

 

Grid column binding with DB column with type converter:

GridViewCheckBoxColumn checkBoxColumn = new GridViewCheckBoxColumn();
checkBoxColumn.DataType = typeof(string);
checkBoxColumn.Name = LocationDo.GenerateSheetsColumn;
checkBoxColumn.FieldName = LocationDo.GenerateSheetsColumn;
checkBoxColumn.HeaderText = "Generate Tests?";
checkBoxColumn.DataTypeConverter = new ToggleStateConverter();
dgvLocations.MasterTemplate.Columns.Add(checkBoxColumn);
dgvLocations.Columns[LocationDo.GenerateSheetsColumn].Width = 55;

 

Property definition:

[TypeConverter(typeof(ToggleStateConverter))]
public string GenerateSheets
{
         get { return _GenerateSheets; }
         set { _GenerateSheets = value; }
}

 

Thanks,

 -Chandra

 

5 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 03 Oct 2016, 11:06 AM
Hi Chandra,

I have attached a small sample that shows how this works. In addition, the following article shows which events should be used for the update: Tracking changes in RadGridView.

I hope this will be useful. Let me know if you have additional questions.

Dimitar
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Chandra Sekhar
Top achievements
Rank 1
answered on 04 Oct 2016, 05:33 PM

Hi Dimitar,

Thanks a lot for the quick reply and the sample application. I actually used the same approach as mentioned in your sample, however it is not behaving as expected. One important thing I have noticed during my debug process is CanConvertTo() is returning false for me as a result the actual ConvertTo() method is not getting called. I tried to go through the stack trace but the pdb files are not available so I couldn't go further on that. If I explicitly return true from the CanConvertTo() method it is checking the check boxes as required. So my question is why would the destinationType == typeof(ToggleState) returns false in my case. Please share your opinions on what could go wrong that the validation which is yielding false. Thanks a lot.

public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)         
        {             
            //bool flag = destinationType == typeof(ToggleState);
            //return flag; 
            return true;
        } 

 

-Chandra.

0
Dimitar
Telerik team
answered on 05 Oct 2016, 11:34 AM
Hello Chandra,

Thank you for writing back.

Perhaps you are using type located in another assembly. Please try by specifying the entire type name: 
return destinationType == typeof(Telerik.WinControls.Enumerations.ToggleState);

Could you please check what type is the "desitinationType" variable holding on your side as well?

I am looking forward to your reply.
 
Regards,
Dimitar
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Chandra Sekhar
Top achievements
Rank 1
answered on 13 Oct 2016, 01:50 PM

Hi Dimitar,

I found the wrong doing in my case, I have implemented the type converter class in a different assembly and then using it in another so it was returning false and hence the conversion not happening. I transferred the type converter code to the same library where i was using that then it is working. I am good for now however ideally this should not be true is what i feel. Correct me if i am wrong. Thanks a lot.

0
Dimitar
Telerik team
answered on 14 Oct 2016, 07:04 AM
Hi Chandra,

Adding the TypeConvertor class to another assembly should work as well. Please note that the other project must reference the Telerik assemblies as well. However, without looking at the prjects I cannot tell wat was wrong in your case.

Let me know if I can assist you further.

Regards,
Dimitar
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Tags
GridView
Asked by
Chandra Sekhar
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Chandra Sekhar
Top achievements
Rank 1
Share this question
or