Binding a List collection to a datagrid. How can you limit what properties will be displayed?
DataGridViewAirport.DataSource = GlobalDisplayAirports
Binding a List collection to a datagrid. How can you limit what properties will be displayed?
DataGridViewAirport.DataSource = GlobalDisplayAirports
Turn off AutoGenerateColumns, and then you can explicitly create the columns you need. For example here's an example:
<asp:GridView ID="myGrid" runat="server" AutoGenerateColumns="False" CellSpacing="0">
<Columns>
<asp:BoundField DataField="Total" HeaderText="Amount" DataFormatString="{0:C}"/>
</Columns>
Another option would to be hide the columns after you data bind, but this above is a better approach.
Depending on your dataSource you could mark the properties you don't want to show then you can leave autogenerate columns on.
I believe this is correct VB:
<System.ComponentModel.Browsable(false)> _
in C# it is
[System.ComponentModel.Browsable(false)]
Another Useful attribute is
[DisplayName("Total Amount")]