Binding Manually Isn't Working Correctly

4 posts, 0 answers
  1. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 22 Sep 2009 Link to this post

    Hello,

    The bind does work, but i have <GridTemplateColumn> and I am using the approach to matching it, but it isn't working correctly.  Instead, it's binding nothing.  I am binding using set_data and calling dataBind, and I do see the rows, but the rows are empty.

    I have a control like:
    <asp:Label id="MyField" runat="server" />

    And I do have a MyField field in the data source, but nothing is binding.  Also, my data keys collection is null... something isn't right...  I also tried GridBoundColumn and that isn't binding correctly either...
  2. Todd Anglin
    Todd Anglin avatar
    2040 posts
    Member since:
    Aug 2005

    Posted 22 Sep 2009 Link to this post

    Hello again Brian-

    It sounds like you're trying to use client-side binding. Is that correct?

    If so, you may want to consider switching to server-side binding with RadAjaxManager providing your "optimized user experience." With client-side binding, you cannot use server control or server-side templates. When you you bind client-side, only JSON is sent over the wire from the server to RadGrid, and today there is no way to "replicate" a server-side template in client-side binding. You can find more notes on this topic and more general resources regarding client-side binding here:


    If you'd like to use GridTemplateColumns and things like ASP.NET Labels, try using server-side binding to something like ObjectDataSource or SqlDataSource. That should make things easier for you - especially if you're still getting familiar with RadGrid.

    -Todd
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Brian Mains
    Brian Mains avatar
    485 posts
    Member since:
    Oct 2008

    Posted 23 Sep 2009 Link to this post

    Hello,

    This is my source of confusion because I am looking at this: http://demos.telerik.com/aspnet-ajax/grid/examples/client/databinding/defaultcs.aspx

    And it has templates and is bound via the client side, and it works fine....
  5. Todd Anglin
    Todd Anglin avatar
    2040 posts
    Member since:
    Aug 2005

    Posted 23 Sep 2009 Link to this post

    The reason the demo you're pointing to works is because the rows with templates are initially created on the server. When working with client-side binding, "basic" templates can used if they are rendered on the server and if the IDs of the controls in the template match the name of the DataField. From the online docs for client-side binding:

    Since RadGrid transfers JSON data when bound on the client, if you have some kind of templates -GridTemplateColumn/ NestedViewTemplate - there is no proper way for populating the controls in these templates as they are templates. However, for the rows that are initially created on the server (these PageSize items), RadGrid will manage to populate a control in GridTemplateColumn  if the control in that ItemTemplate has ID set equal to the DataField property of that column.

    If you want to replicate this scenario, you should be able to do it by following the code examples in the demo you linked to. If your code looks the same as the demo and you're still having problems, let me know and we'll dig deeper.

    -Todd
Back to Top