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

[Solved] Default Values in Database

4 Answers 165 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Stephen asked on 28 Apr 2008, 02:03 PM
Hi,

When I switch into Edit mode in RadGrid, should it be picking up the default values as defined in the table definition in SQL Server.  I have a "bit" SQL field defaulted to -1 in the table design, but the checkbox I have in the EditForm template doesnt default to being checked when I add a new record.

Thanks

Stephen

4 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 29 Apr 2008, 02:07 PM
Hi Stephen,

The checkbox will have no value, since you are inserting a new records. When this is the case, since no values are coming from the database, it will not be checked, also all textboxes will have no text.
You can use the ItemDatabound event handler, to get a reference to the insert item, all the conntrols in it, the checkbox included, and pre-set a default value.

Best wishes,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Stephen
Top achievements
Rank 1
answered on 29 Apr 2008, 02:20 PM
Hi,

I thought that the RadGrid was aware of the database schema.  It would make sense that it should be aware of the schema and set a default value in the databound edit form.

I could understand it not working like this with an ObjectDataSource sitting between the database and the grid (my scenario, so I will use your technique)....but would have thought it would behave as I describe with a straight data connection.

Thanks

Stephen
0
Yavor
Telerik team
answered on 30 Apr 2008, 10:32 AM
Hi Stephen,

Unfortunately, the control will not be aware of these settings. This would make a nice feature suggestion, nevertheless, and I will pass it along to our developers, for consideration.
In the meantime, I hope that the present suggested work-around is feasible for you.

Regards,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Stephen
Top achievements
Rank 1
answered on 30 Apr 2008, 10:48 AM
OK,

Thanks for passing it on.

Regards

Stephen
Tags
Grid
Asked by
Stephen
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Stephen
Top achievements
Rank 1
Share this question
or