Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将dbcontext绑定到gridview并显示数据_C#_Entity Framework_Aspxgridview - Fatal编程技术网

C# 将dbcontext绑定到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

我有一个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>
如何显示没有来自数据库的列名的列

例如,当我将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"; 
    } 
}