ObjectDataSource object and collection of objects

I have a GridView that I would like to bind to an ObjectDataSource. I have a ReadOnlyCollection of Business Objects that have many properties. I only need to display four of these properties in a GridView. I haven't used the ObjectDataSource control before, so how can I use it to display 4 properties of all business objects in my ReadOnlyCollection?

0


source to share


1 answer


Let's say you have a list of objects with two properties: Name and Age:

<asp:GridView ID="gvwExample" runat="server" AutoGenerateColumns="False" 
  DataSourceId="myObjectDataSource">
  <columns>
    <asp:BoundField DataField="Name" HeaderText="Name" />
    <asp:BoundField DataField="Age" HeaderText="Age" />
  </columns>
</asp:GridView>

      



The same as what you would do if you were data binding to any source and didn't want every value of every data row.

+1


source







All Articles