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

Problems binding RadGrid to generic list

2 Answers 142 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Duane Roelands
Top achievements
Rank 1
Duane Roelands asked on 23 May 2013, 05:38 PM
My gird is declared like so:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="list.aspx.vb" Inherits="User_list" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" Runat="server"></telerik:RadScriptManager>
        <telerik:RadGrid ID="UserGrid" runat="server" AutoGenerateColumns="False"  CellSpacing="0" GridLines="None" runat="server">
            <MasterTableView>
                <Columns>
                    <telerik:GridBoundColumn AllowFiltering="False" DataField="EmailAddress"
                        FilterControlAltText="Filter column column" HeaderText="User"
                        UniqueName="column">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="FullName"
                        FilterControlAltText="Filter column1 column" HeaderText="Full Name"
                        UniqueName="column1">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
    </form>
</body>
</html>

...and I bind to a generic list in the codebehind...

Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
    If Not Page.IsPostBack Then
        Dim Users As List(Of User) = UserManager.GetAll(ApplicationVariables.CurrentUser.InstitutionId)
        UserGrid.DataSource = Users
        UserGrid.DataBind()
    End If
End Sub

My list ("Users") is a list of objects with the following definition:
Public Class User
    Public UserId As Integer = 0
    Public Password As String = String.Empty
    Public EmailAddress As String = String.Empty
    Public InstitutionId As Integer = 0
    Public FullName As String = String.Empty
End Class

There are two users in my source data.  The grid displays the right number of rows, but the cells are empty:
Empty Grid

I'm sure this is an obvious mistake.  Any help is appreciated.

2 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 28 May 2013, 11:42 AM
Hello,

Thank you for contacting us.

Generally, your code looks correct. However, you have not shared what is the body of the GetAll method and how the data is initialized.

Could you share your full page source code along with the code-behind file? Thus I will be able to examine your code and let you know what could possibly lead to this behavior.

I am looking forward your reply.

Regards,
Andrey
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Duane Roelands
Top achievements
Rank 1
answered on 28 May 2013, 11:54 AM
It turns out that the source of my problem was that my user class exposed public members, but they were not properties. Once I changed the public members to be properties, the grid rendered correctly. Thanks for checking into it.
Tags
Grid
Asked by
Duane Roelands
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Duane Roelands
Top achievements
Rank 1
Share this question
or