VB.Net GridView Object Values

by Linda Quinn

Close Window



When a Gridview uses an object data source, that object may contain other objects.

How do I display a single value from the embedded object in my Gridview?

For example, I have a list of order line objects that I want to display in a GridView. The order line object contains another object which is product. But in my GridView, I only want to list the product name.


    <asp:GridView ID=gridView1 runat=server ....  
       <Columns> 
           <asp:TemplateField HeaderText=" Product"> 
                <EditItemTemplate> 
                
                   <asp:TextBox ID=Product runat=server 
                            Text= <%# Eval(" Product.ProductName ") %>
                   </asp:TextBox>
                
                </EditItemTemplate>
           </asp:TemplateField>
       </Columns>
    </asp:GridView>
    



=================================================================
This content was created by Linda Quinn of LQNet.

See http://www.lqnet.com for a great collection of articles on this and other topics.

=================================================================
Copyright © 2006-2009, LQ Systems,Inc. All rights reserved.


====================================================================
Want an expert to help with your project?    LQ Systems, Inc.   Business Solutions
====================================================================