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

[Solved] Grid shows empty eventhough Model data is populated.

2 Answers 33 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Laura
Top achievements
Rank 1
Laura asked on 08 Jun 2011, 09:12 PM
Hi, I keep getting the Grid empty, but the Model is populated, any help will be appreciated. The grid is on a partial view, here is the view:

<% Html.Telerik().Grid<AgdataFtp.WebUI.Models.EntityPermissions>()
                .Name("Grid")
                .Columns(col => {
                    col.Bound(Model.EntityName).Title("Business Group");
                    col.Template(o =>
                    {
                        for (int i=0; i < Model.EffectivePermissions.Count; i++)
                        { %>
                            <table cellspacing="0" class="data-row">
                            <tr>
                                <td> <%= Html.Encode(Model.EffectivePermissions[i].UserName) %>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <input type="checkbox" name="DownloadAccessChecked"
                                        checked=" <%= Html.Encode(Model.EffectivePermissions[i].DownloadAccess)%> "/> </td>
                                <td>
                                    <input type="checkbox" name="DownloadAccessChecked"
                                        checked="<%= Html.Encode(Model.EffectivePermissions[i].UploadAccess)%> "/> </td>
                                <td>
                                    <input type="checkbox" name="NotifyDownloadChecked"
                                        checked="<%= Html.Encode(Model.EffectivePermissions[i].GetNotifyStatus())%> "/> </td>
                                <td> <input type="checkbox" name="NotifyUploadChecked" /> </td>
                            </tr
                            </table>      
                            <% }
                    }).Width(270)
                    .HeaderTemplate(() =>
                    { %>
                        <table cellspacing="0" class="data-header">
                        <tr> <td colspan="4" align="center"> <strong>User</strong> </td> </tr>
                        <tr>
                            <td colspan="2" align="center">
                                <strong>Access</strong>
                            </td>
                            <td colspan="2" align="center">
                                <strong>Notification</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>Download</td>
                            <td>Upload</td>
                            <td>Download</td>
                            <td>Upload</td>
                        </tr>
                    </table>
                    <% })
                    .HeaderHtmlAttributes(new { style = "text-align:center" })
                    .HtmlAttributes(new { style = "text-align:center" })
                    .Width(270);
                    })
                .Footer(false)
                .Render();
     
%>

The partial view is render on a normal view:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<AgdataFtp.WebUI.Models.GridPermissionsModel>" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    ExternalPermissions
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="indent">
        <div class="clear">
            <% if (Model.BGNames != null)
               { %>
            <%=  Html.Telerik().ComboBox().Name("BG_DropDownList")
                               .BindTo(new MultiSelectList(Model.BGNames)).SelectedIndex(0) %>
            <% } %>
            <%= Html.Telerik().ComboBox().Name("Client_DropDownList")
                               .BindTo(new MultiSelectList(Model.CNames)).SelectedIndex(0) %>
            <%= Html.Telerik().ComboBox().Name("User_DropDownList")
                               .BindTo(new MultiSelectList(Model.UNames)).SelectedIndex(0) %>
        </div>
        <div class="clear"></div>
 
        <div>
                       
        <%  foreach (var ep in Model.userBGPermissions)
            {
                Html.RenderPartial("CreateGrid", ep);
            }
        %>
          </div>
    </div>
</asp:Content>

And the model data is populated on the controller action:

public ActionResult ExternalPermissionsUpdate()
        {
            if (loggedUser.UserRol == "Administrator")
            {
                gridModel.BGNames = sqlRepository.GetAllBusinessGroups();
                gridModel.CNames = sqlRepository.GetAllClients();
                gridModel.UNames = sqlRepository.GetActiveUsers();
            }
            else
            {
                gridModel.CNames = sqlRepository.GetClientForUser(loggedUser.UserName);
                gridModel.UNames = sqlRepository.GetActiveUsers(loggedUser.UserName);
            }
            //Permissions x User
            for (int i = 0; i < gridModel.BGNames.Count; i++)
            {
                gridModel.AddBusinessGroupPermission(gridModel.BGNames[i], sqlRepository.GetBusinessGroupPermissions(gridModel.BGNames[i]));
                gridModel.AddClientPermission(gridModel.BGNames[i], sqlRepository.GetClientPermissions(gridModel.BGNames[i]));
            }
 
            ViewData.Model = gridModel;
            return View("ExternalPermissionsUpdate");
        }

I have checked that the model is populated, but all I get is an empty table on the page.

2 Answers, 1 is accepted

Sort by
0
Laura
Top achievements
Rank 1
answered on 09 Jun 2011, 09:17 PM
Hi,
Does anyone know why this is happening, the Grid displays rows for all the data on the Model.EffectivePermissions list, but all empty rows.



0
Accepted
Atanas Korchev
Telerik team
answered on 10 Jun 2011, 07:50 AM
Hi Laura,

 Your grid is never bound to any data. I suggest you check the server binding help topic for further instructions.


Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Laura
Top achievements
Rank 1
Answers by
Laura
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or