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

Bind to database on GridEditFormInsertItem

3 Answers 135 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 12 May 2015, 03:25 PM

I have a radgrid with command buttons to edit items or insert new items.  When editing items, my edit form template has several checkboxes.  I bind the "checked" attribute of these checkboxes to bits in the database to see if they should be checked when the form loads, like so:

 This works just fine when editing, but it doesn't work when inserting a new item since it's a new item and there is no database value to bind to.  So I found code that lets you specify if it is and insert item or not.  The problem is I can't figure out how to do a database bind when using it.  I need something like this:

 when I try this I get the follwing error:

Error 24 The name 'Bind' does not exist in the current context 

I have to believe this is possible, my context is just wrong.  Does anyone know what I am doing wrong?


3 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 1
answered on 12 May 2015, 03:28 PM

Apparently I can't include screenshots like I thought I could in the post, I will just copy paste the code in....

I have a radgrid with command buttons to edit items or insert new items.  When editing items, my edit form template has several checkboxes.  I bind the "checked" attribute of these checkboxes to bits in the database to see if they should be checked when the form loads, like so: 

 <asp:CheckBox ID="cbSignUp" Text="Allow Sign Ups" TextAlign="Right" runat="server"
                                                    Checked='<%# Bind("sign_up") %>' />

This works just fine when editing, but it doesn't work when inserting a new item since it's a new item and there is no database value to bind to.  So I found code that lets you specify if it is and insert item or not.  The problem is I can't figure out how to do a database bind when using it.  I need something like this:

 <asp:CheckBox ID="cbAutoAssign" Text="Allow Auto Assignment" TextAlign="Right" runat="server"
        Checked='<%# (Container is GridEditFormInsertItem) ? Convert.ToBoolean("False") : Bind("auto_assign") %>'  />

 when I try this I get the following error:

Error 24 The name 'Bind' does not exist in the current context

 I have to believe this is possible, my context is just wrong.  Does anyone know what I am doing wrong?

0
Kostadin
Telerik team
answered on 15 May 2015, 09:57 AM
Hi Kevin,

I would recommend you to examine the following forum thread where the same issue is already discuss.

Regards,
Kostadin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Kevin
Top achievements
Rank 1
answered on 15 May 2015, 02:33 PM
That approach worked for me.  Thanks for the reply.
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or