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

GridTemplateColumn not binding data using RadClientDataSource for Radgrid

1 Answer 165 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dhamodharan
Top achievements
Rank 1
Dhamodharan asked on 24 Dec 2014, 06:54 AM
Hi All,
I am using RadClientDataSource for binding radgrid. I want to create Required field validation for one column. so that i created one GridTemplateColumn. but that column not binding data. please check my code and let us know what needs to be done.

 <telerik:GridTemplateColumn DataField="description" UniqueName="description" HeaderText="Description">
                    <ItemTemplate>
                    <asp:Label ID="lblDescription" runat="server" Text='<%# Eval("description") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                    <telerik:RadTextBox ID="rtbDescription" runat="server" Text='<%# Bind("description") %>'></telerik:RadTextBox>
                      <asp:RequiredFieldValidator ID="rfvDescription" runat="server" ControlToValidate="rtbDescription" Display="Dynamic"
                                ErrorMessage="Please enter Description" ForeColor="Red" ></asp:RequiredFieldValidator>
                    </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <%--<telerik:GridBoundColumn DataField="description" HeaderText="Description" ColumnEditorID="GridTextBoxEditor">
                    </telerik:GridBoundColumn>--%>

Thanks in Advance,
Dhamu

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 26 Dec 2014, 12:54 PM
Hello Dhamodharan,

With client-side binding you should use the ClientItemTemplate for the GridTemplateColumn:
<telerik:GridTemplateColumn DataField="description" UniqueName="description" HeaderText="Description">
    <ClientItemTemplate>
        #= description #
    </ClientItemTemplate>
    <EditItemTemplate>
        <telerik:RadTextBox ID="rtbDescription" runat="server"></telerik:RadTextBox>
        <asp:RequiredFieldValidator ID="rfvDescription" runat="server" ControlToValidate="rtbDescription" Display="Dynamic"
            ErrorMessage="Please enter Description" ForeColor="Red"></asp:RequiredFieldValidator>
    </EditItemTemplate>
</telerik:GridTemplateColumn>

The expressions that you are trying to use are for server-side binding and will not work with client-side binding.

Additionally, since the editing with client-side binding is available only with Batch Editing, you do not need to set the Text property of the RadTextBox, because the BatchEditingManager will retrieve the value from the cell.

On a side note, each bound column exposes internal validators that could be used, so you can avoid using GridTemplateColumn:
<telerik:GridBoundColumn DataField="description">
    <ColumnValidationSettings EnableRequiredFieldValidation="true" RequiredFieldValidator-Display="Dynamic">
        <RequiredFieldValidator ErrorMessage="Please enster Description" ForeColor="Red"></RequiredFieldValidator>
    </ColumnValidationSettings>
</telerik:GridBoundColumn>

Hope this helps.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Dhamodharan
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or