我有一个 GridView :
<asp:GridView ID="ParentSelect" runat="server" AutoGenerateColumns="false" OnRowCommand="ParentSelect_RowCommand" OnRowCreated="ParentSelect_RowCreated" emptydatatext="Please Submit A Clip. C'mon dude." ShowHeaderWhenEmpty="true" HorizontalAlign="Center" Width="600" CssClass= "table table-striped table-bordered table-condensed">
<HeaderStyle BorderColor="Black" />
<Columns>
<asp:BoundField DataField ="dbContext.Mains.VideoUrl" HeaderText="Title" Visible="false" />
</Columns>
</asp:GridView>
并且我已经绑定(bind)了我的 DBCONTEXT:
protected void LoadGrid()
{
ParentSelect.DataSource = dbContext.Mains.ToList();
ParentSelect.DataBind();
}
我想通过 BoundField 在我的 gridview 上显示数据库中的数据。我怎样才能做到这一点? 请谢谢。
最佳答案
就这么简单:
<asp:BoundField DataField ="VideoUrl" HeaderText="Title" />
关于c# - 通过 boundfield 将 DBCONTEXT 绑定(bind)到 gridview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27743274/