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

Bound to MySQL Bit Column Question

5 Answers 65 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bkoenig
Top achievements
Rank 1
Bkoenig asked on 12 Jul 2013, 09:56 PM
Hello,

I have a table in a MySQL database that is getting hit via a Stored Procedure inside of a MySQL database.  The column type is a BIT(1) which according to the MySQL documentation is the correct way to implement a Boolean field into the database.  I don't really want to hard code the columns in to allow for some flexibility.  I would hate to have to update this GUI every time I add something new to the database.

I went to one of the BIT columns that are located in the RadGridView and it appears to be an Numeric column because the range of accepted values is -79228162514264337593543950335 to 79228162514264337593543950335.   Not to sound like a wise guy, but putting anything other than 0 or 1 into a BIT(1) column will cause the database to have an aneurysm.

Any help is much appreciated.

5 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 17 Jul 2013, 10:02 AM
Hi Brendon,

Thank you for writing.

In your case you will have to change the column type in RadGridView by deleting the numeric column and adding a checkbox column bound to the BIT(1) field. Here is how to do that:
radGridView1.Columns.RemoveAt(1); //where 1 is the index of the numeric BIT column
 
GridViewCheckBoxColumn col = new GridViewCheckBoxColumn();
radGridView1.Columns.Add(col);
col.FieldName = "testColumn"; //where testColumn is the name of the BIT field

Please give this approach a try and let me know how it works for you.
 
Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Bkoenig
Top achievements
Rank 1
answered on 17 Jul 2013, 12:48 PM
Hello Stefan,

Is this the only solution currently?  I was hoping for a solution that would be less static.

Just as a side note, if this is just a bug in Q2 2013, I think this should be added to the list for Q3 2013.  If its not a feature currently, it would be somewhat of a useful feature because it would eliminate code such as the code mentioned.  Especially since I have a list of 16 Bit Columns that I would have to hard code just for one gridview.

Thank you,
Brendon
0
Stefan
Telerik team
answered on 19 Jul 2013, 11:05 AM
Hi Brendon,

This is not a bug, it is how RadGridView works. The BIT field in MySQL is a numeric field and RadGridView creates a numeric column for it when generating the columns automatically. As you want to interpret the field in a different manner, you have to replace the column with the one you want.

I hope that you find this information useful.
 

Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Bkoenig
Top achievements
Rank 1
answered on 19 Jul 2013, 02:22 PM
Hello Stefan,

Thank you for that insight.  Doing research into that information, the BIT is stored as the numeric data type of TINYINT(1).  This leads me to a related question.  Why is the RadGrid column allow such a large number into such a column.

Thank you
0
Stefan
Telerik team
answered on 24 Jul 2013, 09:53 AM
Hi,

Whem the grid detects a numeric value, by default it creates GridViewDecimalColumn which has a default DataType of decimal, hence the large number observed.

I hope you find this information useful.
 

Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Bkoenig
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Bkoenig
Top achievements
Rank 1
Share this question
or