简体   繁体   中英

ASP.net C# Populating Gridview columns from list

I am trying to bind a list to specific columns, I can get it to autogenerate columns from the list but I want to specify a column to populate

        GridView1.DataSource = carlist;
        GridView1.DataBind();

We don't know what type carlist contains, but assuming contains car objects that have a ModelName property:

  <asp:GridView  AutoGenerateColumns="False" ID="myGrid" runat="server">

   <asp:BoundField HeaderText="Model Name" DataField="ModelName" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM