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

RadDataForm Child Controls

6 Answers 175 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Wally
Top achievements
Rank 1
Wally asked on 13 Mar 2020, 04:42 PM
I have a RadDataForm that is databound to a SQLDataSource.  If I use a RadTextBox within a Div within the EditTemplate, the value entered into that RadTextBox is sent to the database.  However, if I put that RadTextBox within a Table->TableRow->TableCell in the Div, the value entered into that RadTextBox is never sent to the database, nor is it still in the form after the update.  Are there restrictions on how controls can be embedded within the EditTemplates when editing data?

6 Answers, 1 is accepted

Sort by
0
Doncho
Telerik team
answered on 18 Mar 2020, 09:49 AM

Hi Wally,

Similar to the Data Binding Selected Value forum thread, the RadTextBox must also have the Bind() expression defined or otherwise the RadDataForm will not pick up the introduced values.

<telerik:RadTextBox ID="RadTextBox1" runat="server" Text='<%# Bind("SomeFieldInTheDatabase") %>''></telerik:RadTextBox> 

 

Regards,
Doncho
Progress Telerik

Get quickly onboarded and successful with UI for ASP.NET AJAX with the Virtual Classroom technical trainings, available to all active customers. Learn More.
0
Wally
Top achievements
Rank 1
answered on 18 Mar 2020, 01:03 PM

The Bind() statement wasn't the question.  I clearly state that I'm able to send data to the database having just the RadTextBox within the Div.  The default-generated templates do this.  However, what I'm trying to do is embed the RadTextBox within an ASP Table to have more control over the layout.  Something like this:

<asp:Table runat="server">
<asp:TableRow>
<asp:TableCell>
<telerik:RadTextBox ID="RadTextBox1" runat="server" Text='<%# Bind("SomeFieldInTheDatabase") %>' />
</asp:TableCell>
</asp:TableRow>
</asp:Table>

That does not write the value entered into the RadTextBox into the database.  It's as if the control and its value are not seen when clicking the Update button.

0
Doncho
Telerik team
answered on 18 Mar 2020, 03:34 PM

Hi Wally,

Would you explain what did you mean by "default-generated templates"? We may have examples with some templates, but there is no explicit default. Can you tell me more about, or show me those templates?

 

When working with Templates, the Bind() is necessary for the Controls to pick up the values entered by the user. Otherwise, that will not happen.

Here is an example showing that

Assuming that we have the following DataForm structure. I am only displaying the important part.

<telerik:RadDataForm runat="server" ID="RadDataForm1" OnItemUpdating="RadDataForm1_ItemUpdating">

    <LayoutTemplate>
        <%--pager and layout here--%>
    </LayoutTemplate>

    <ItemTemplate>
        <%--some controls here--%>
    </ItemTemplate>

    <EditItemTemplate>
        <telerik:RadTextBox ID="RadTextBox1" runat="server"></telerik:RadTextBox>
    </EditItemTemplate>

</telerik:RadDataForm>

 

In this case, if I fill the textbox and click on Update, the values will not be present on the server-side.

Debugging code on the  server shows no values:

 

 

If, however, I bind the RadTextBox using the server-side Bind() expression like in the code snippet below:

<EditItemTemplate>
    <telerik:RadTextBox ID="RadTextBox1" runat="server" Text='<%# Bind("SomeFieldName") %>'></telerik:RadTextBox>
</EditItemTemplate>

and then updating the form like this

Server-Side Debugging shows the values present on the server:

 

Embedding the RadTextBox in a table like shown below, doesn't change the behavior and the binding will still be working

<EditItemTemplate>
    <asp:Table ID="Table1" runat="server">
        <asp:TableRow>
            <asp:TableCell>
                <telerik:RadTextBox ID="RadTextBox1" runat="server" Text='<%# Bind("ShipName") %>'></telerik:RadTextBox>
            </asp:TableCell>
        </asp:TableRow>
    </asp:Table>
</EditItemTemplate>

 

It would be very helpful if you could share more information about the current structure, the way you bind data to the DataForm and the server-side code if doing Manual CRUD operations.

Kind regards,
Doncho
Progress Telerik

Get quickly onboarded and successful with UI for ASP.NET AJAX with the Virtual Classroom technical trainings, available to all active customers. Learn More.
0
Wally
Top achievements
Rank 1
answered on 18 Mar 2020, 03:36 PM
After testing various scenarios, including using the base ASP.Net FormView, just using HTML tables instead of ASP tables, and a combination of both, I've found the actual problem here.  It turns out, you can't use the CompareAllValues ConflictDetection on the SqlDataSource when you have your editor controls embedded into a table (of either type).  Instead, you have to set ConflictDetection to OverwriteChanges (and don't check the "Use optimistic concurrency" checkbox when generating Insert, Update, and Delete statements in the Configure wizard)
0
Wally
Top achievements
Rank 1
answered on 18 Mar 2020, 03:39 PM
The "default-generated templates" I'm referring to is when you go to the Smart Tag on the RadDataForm, choose Open Configuration Wizard, and then choose one of the three options on the Layout tab.  But, as you can see above, I figured out where the actual problem is - it's "underneath" your control either with the base ASP.Net FormView or the SQLDataSource.
0
Doncho
Telerik team
answered on 23 Mar 2020, 03:20 PM

Hello Wally,

The ConflictDetection property of the SqlDataSource is related to how the SQL Update is performed, its an action between SqlDataSource and the database. This property defines whether conflicts should be detected before the operation is completed.

On the other hand, using ASP Tables, or HTML tables, and whether they are placed inside Telerik RadDataForm or ASP DataForm, they are rather related to HTML Structure and have no impact on how the SQL operation is being performed.

I advise that you check out the official documentation to get a better understanding: SqlDataSource.ConflictDetection Property

Kind regards,
Doncho
Progress Telerik

Get quickly onboarded and successful with UI for ASP.NET AJAX with the Virtual Classroom technical trainings, available to all active customers. Learn More.
Tags
DataForm
Asked by
Wally
Top achievements
Rank 1
Answers by
Doncho
Telerik team
Wally
Top achievements
Rank 1
Share this question
or