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

Binding Manually Isn't Working Correctly

3 Answers 45 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brian Mains
Top achievements
Rank 1
Brian Mains asked on 22 Sep 2009, 02:10 PM
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...

3 Answers, 1 is accepted

Sort by
0
Todd Anglin
Top achievements
Rank 2
answered on 23 Sep 2009, 03:42 AM
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
0
Brian Mains
Top achievements
Rank 1
answered on 23 Sep 2009, 01:37 PM
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....
0
Todd Anglin
Top achievements
Rank 2
answered on 23 Sep 2009, 05:02 PM
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
Tags
Grid
Asked by
Brian Mains
Top achievements
Rank 1
Answers by
Todd Anglin
Top achievements
Rank 2
Brian Mains
Top achievements
Rank 1
Share this question
or