C# 将dbcontext绑定到gridview并显示数据
我有一个gridview:C# 将dbcontext绑定到gridview并显示数据,c#,entity-framework,aspxgridview,C#,Entity Framework,Aspxgridview,我有一个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" H
<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>
如何显示没有来自数据库的列名的列
例如,当我将autogeneratecolumns设置为“true”时,它将显示数据库中的列名,但我希望以不同的名称显示列中的相同数据
因此,我不想使用VideoUrl(db列的名称),而是想以某种方式屏蔽它,以便数据来自VideoUrl,但它有另一个名称,如“URL”
谢谢你的帮助 您可以在RowDataBound事件中处理它
protected void ParentSelect_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[2].Text = "URL";
}
}
protected void ParentSelect_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[2].Text = "URL";
}
}