我似乎无法让列显示在页面上。我想用列显示gridview,但没有任何数据。我怎样才能做到这一点?
**Presenter.cs**
public DataTable GetAllSelectedColumns(int onderzoekId)
{
DataTable dt = new DataTable();
var onderzoek = OnderzoekModel.GetOnderzoek(onderzoekId);
foreach (var cn in OnderzoekColumnModel.GetSelectedColumns(onderzoek.OnderzoekId))
{
dt.Columns.Add(cn.ColumnName);
}
return dt;
}
**Page.aspx**
<asp:Panel runat="server" ID="pnlContainer" CssClass="onderzoek-data">
<asp:GridView ID="mainGridViewFixedColumns" runat="server" AutoGenerateColumns="False" ShowHeaderWhenEmpty="True">
</asp:GridView>
<asp:GridView ID="mainGridView" runat="server" Font-Size="Small">
<HeaderStyle CssClass="GVHeader" />
<FooterStyle CssClass="GVFooter" />
</asp:GridView>
</asp:Panel>
**Codebehind**
public void DisplayFixedColumns(DataTable data)
{
mainGridViewFixedColumns.DataSource = data;
mainGridViewFixedColumns.DataBind();
}