Binded check box column data type issue

6 posts, 0 answers
  1. Chandra Sekhar
    Chandra Sekhar avatar
    5 posts
    Member since:
    Sep 2016

    Posted 30 Sep Link to this post

    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

     

  2. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 03 Oct Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Chandra Sekhar
    Chandra Sekhar avatar
    5 posts
    Member since:
    Sep 2016

    Posted 04 Oct in reply to Dimitar Link to this post

    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.

  5. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 05 Oct Link to this post

    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.
  6. Chandra Sekhar
    Chandra Sekhar avatar
    5 posts
    Member since:
    Sep 2016

    Posted 13 Oct in reply to Dimitar Link to this post

    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.

  7. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 14 Oct Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready