Binding to webservice client side, GridTemplateColumn not binding

2 posts, 1 answers
  1. Arni Gunnar Ragnarsson
    Arni Gunnar Ragnarsson avatar
    13 posts
    Member since:
    Jul 2007

    Posted 31 Jul 2008 Link to this post

    I am using the new awesome feature of the RadGrid to be able to bind to a webservice using ASP.NET AJAX + WS + RadGrid.

    This is the definition of my grid:
        <telerik:RadGrid ID="RoundList" AutoGenerateColumns="false" Skin="Gray" runat="server">
            <MasterTableView TableLayout="Fixed" DataKeyNames="ID">
                    <telerik:GridBoundColumn DataField="ID" HeaderText="#" />
                    <telerik:GridTemplateColumn HeaderText="Delete">
                            <a href="#" onclick="DeleteRow(<%#Eval("ID")%>);return false;">Delete</a>
                <ClientEvents OnCommand="function(){}" />
    The GridBoundColumn works fine, the ID shows up there, but in the GridTemplateColumn, the ID is blank.

    Anyone know what I am doing wrong ??
  2. Answer
    Vlad avatar
    11100 posts

    Posted 01 Aug 2008 Link to this post


    Currently we don't have binding expressions for client-side data-binding and you can use OnRowDataBound event to populate controls client-side. Please check these examples:
    the second column in this example is template column. You can use findControl() client-side method to find an ASP.NET AJAX Control:

    function RadGrid1_RowDataBound(sender, args)
     var radTextBox1 = args.get_item().findControl("RadTextBox1");
    in these examples you can check client-side helper method called getElement():
                function getElement(parent, id) { 
                    var children = parent.getElementsByTagName("*"); 
                    for (var i = 0, l = children.length; i < l; i++) { 
                        var child = children[i]; 
                        if ( 
                            return child; 
                    return null

    <telerik:GridTemplateColumn HeaderText="Delete">
    <a href="#" onclick="DeleteRow(<%#Eval("ID")%>);return false;">Delete</a>
    function RadGrid1_RowDataBound(sender, args) 
     var cell = args.get_item().get_cell("MyColumn"); 
     var link = cell.getElementsByTagName("a")[0]["onclick"] = String.format("DeleteRow('{0}');", args.get_dataItem()["ID"]); 

    Best wishes,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top