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

Client-side databindning and ItemTemplate

2 Answers 140 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ozzie
Top achievements
Rank 1
Ozzie asked on 22 Feb 2009, 01:49 PM
Hello,
I have managed to achieve a simple client-side databinding after looking at the corresponding demo example. My datafield 'Name' show up as it shall below.
<telerik:RadGrid AutoGenerateColumns="false" ID="RadGrid1" runat="server">
   <MasterTableView TableLayout="Fixed">
      <Columns>
         <telerik:GridBoundColumn DataField="Name" HeaderText="Name" />
      </Columns>
   </MasterTableView>
   <ClientSettings>
      <ClientEvents OnCommand="function(){}" />
   </ClientSettings>
</telerik:RadGrid>

But if I would like to use an ItemTemplate, as I use to do with normal ASP DataControls, to have more control on how my radGrid shall look like, how do I do then?  And can I use code-behind functions together with eval when my radGrid is client-side databounded. When I try like below I receive the following error: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Name'.

<telerik:RadGrid AutoGenerateColumns="false" ID="RadGrid1" runat="server">
   <MasterTableView TableLayout="Fixed">
      <Columns>
         <telerik:GridTemplateColumn>
            <ItemTemplate>
               <div>
                  <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name")%>'
                          ForeColor='<%# CheckColor(Eval("Id"))%>'>
                  </asp:Label>
                </div>
             </ItemTemplate>
          </telerik:GridTemplateColumn>
       </Columns>
    </MasterTableView>
    <ClientSettings>
       <ClientEvents OnCommand="function(){}" />
    </ClientSettings>
</telerik:RadGrid>

I have a working example, which is more like the Ajax timer demo example, which I now want to transforn to one with client-side databinding. In my OnItemDataBound event there I call a javascript function (with registerStartupScript) with one DataListItem (decided from database) as parameter. Any ideas how one can do the same thing now.

2 Answers, 1 is accepted

Sort by
0
Accepted
Sebastian
Telerik team
answered on 25 Feb 2009, 09:35 AM
Hello Ozzie,

With client-side binding for RadGrid for ASP.NET AJAX your option would be to use ASP.NET 4.0 client-side templates (note that they are still in preview version). Review the sample project from the following blog post for more details:

http://blogs.telerik.com/vladimirenchev/posts/08-07-24/Telerik_RadGrid_for_ASP_NET_AJAX_Q2_2008_client-side_edit_using_templates.aspx

Kind regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ozzie
Top achievements
Rank 1
answered on 25 Feb 2009, 12:45 PM
Ok, thanks!
Tags
Grid
Asked by
Ozzie
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Ozzie
Top achievements
Rank 1
Share this question
or