Sharepoint WebPart未出现

时间:2012-11-27 10:51:33

标签: sharepoint gridview web-parts

我有一个SharePoint VisualWebPart,我想在其上放置一个GridView。问题是GridView没有出现在页面上的WebPart中。

这是网格:

<asp:Gridview ID="timeSheetGridView" runat="server" EnableModelValidation="True" AutoGenerateColumns="False">
    <Columns>
        <asp:TemplateField HeaderText="Proiect"></asp:TemplateField>
        <asp:TemplateField HeaderText="User"></asp:TemplateField>
        <asp:TemplateField HeaderText="Task"></asp:TemplateField>
        <asp:TemplateField HeaderText="Ore"></asp:TemplateField>
        <asp:TemplateField HeaderText="Data Start"></asp:TemplateField>
    </Columns>
</asp:Gridview>

在这里我创建了DataBinding

if (timeSheet != null)
{
    foreach (TimeSheetActualValue actualValue in timeSheet.ActualValues)
    {
        actualValuesList.Add(new InitialReportEntity
                             {
                                 ProjectName = proiect.Name,
                                 ResourceName = currentUser,
                                 TaskName = task.Name,
                                 Hours = (int)actualValue.ActualValue / 60000, 
                                 Date = actualValue.StartDate
                              });
    }
}

if (actualValuesList.Count > 0)
{
    timeSheetGridView.DataSource = actualValuesList;
}

1 个答案:

答案 0 :(得分:0)

尝试调用timeSheetGridView.DataBind();