Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6033553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:29:58+00:00 2026-05-23T05:29:58+00:00

I’m loading a gridview with a list of objects and I’m having trouble calling

  • 0

I’m loading a gridview with a list of objects and I’m having trouble calling some of the nested properties on the aspx page. I know the list contains them, and they can be returned, because I’ve used a print method to call up several of the properties in question. The specifics: Submission objects contain nested objects Cust, Bro, and SubCoverage, each of which have their own properties I’m storing in the list and trying to call up for the gridview. Properties of the Submission object itself show up fine, but when I call up the CustName1 property of the Cust object, it’s “Field not found on the selected datasource”. Since I know the data is there, and callable by other methods in the codebehind, I’m assuming it’s a simple syntax thing, but I’ve tried enough iterations to make me wonder if there’s something I’m missing. What is it? Code below:

// The submission class/object:

public class Submission 
{

    private int SubmissionId;

    public int SubmissionId1
    {
        get { return SubmissionId; }
        set { SubmissionId = value; }
    }

    private string Status;

    public string Status1
    {
        get { return Status; }
        set { Status = value; }
    }

    private string StatusComment;

    public string StatusComment1
    {
        get { return StatusComment; }
        set { StatusComment = value; }
    }


    private List<Product> Products = new List<Product>();

    public List<Product> Products1
    {
        get { return Products; }
        set { Products = value; }
    }

    private Customer Cust;
    public Customer _Cust
    {
        get { return Cust; }
        set { Cust = value; }
    }
    private Broker Bro;
    public Broker _Bro
    {
        get { return Bro; }
        set { Bro = value; }
    }


    private SubmissionCoverage Subcov;

    public SubmissionCoverage _SubCov
    {
        get { return Subcov; }
        set { Subcov = value; }
    }

    public Submission()
    {
        Cust = new Customer();
        Bro = new Broker();
        Subcov = new SubmissionCoverage();
    }
}

//One of the nested object classes, Customer:

public class Customer 

{

private int CustId;

public int CustId1
{
    get { return CustId; }
    set { CustId = value; }
}


private string CustName;

public string CustName1
{
    get { return CustName; }
    set { CustName = value; }
}


private string CustAddress;

public string CustAddress1
{
    get { return CustAddress; }
    set { CustAddress = value; }
}


private string CustState;

public string CustState1
{
    get { return CustState; }
    set { CustState = value; }
}

private string CustCity;

public string CustCity1
{
    get { return CustCity; }
    set { CustCity = value; }
}


private int CustZip;

public int CustZip1
{
    get { return CustZip; }
    set { CustZip = value; }
}

private int SicNaic;

public int SicNaic1
{
    get { return SicNaic; }
    set { SicNaic = value; }
}

}

//The query/list data layer:

Submission tempSubmission = new Submission();
        while (dr.Read())
        {
            tempSubmission = new Submission();
            tempSubmission.SubmissionId1 = dr.GetInt32(0);
            tempSubmission._Cust.CustName1 = dr.GetString(1);
            tempSubmission._Cust.CustCity1 = dr.GetString(2);
            tempSubmission._Cust.CustState1 = dr.GetString(3);
            tempSubmission._Bro.BroName1 = dr.GetString(4);
            tempSubmission._Bro.BroState1 = dr.GetString(5);
            tempSubmission._Bro.Entity1 = dr.GetString(6);
            tempSubmission._SubCov.Coverage1 = dr.GetInt32(7);
            tempSubmission.Status1 = dr.GetString(8);

            lstSubmission.Add(tempSubmission);

        }
        return lstSubmission;
    }   

}

// The gridview code:

 <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="false" EmptyDataText="There are no data records to display." AllowPaging="True" 
    BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" 
    CellPadding="3" GridLines="Vertical" HorizontalAlign="Center" 
    AllowSorting="True" >
    <AlternatingRowStyle BackColor="#DCDCDC" />
<Columns>

        <asp:BoundField DataField="SubmissionId1" HeaderText="Submission Id" 
            SortExpression="SubmissionId1" >
        </asp:BoundField>
        <asp:BoundField DataField="_Cust.CustName1" HeaderText="Customer" 
            SortExpression="tempsub._Cust.CustName1" />
        <asp:BoundField DataField="CustCity1" HeaderText="Customer City" 
            SortExpression="CustCity1" />
        <asp:BoundField DataField="CustState1" HeaderText="Customer State" 
            SortExpression="CustState1" />
        <asp:BoundField DataField="BroName1" HeaderText="Broker" 
            SortExpression="BroName1" />
        <asp:BoundField DataField="BroState1" HeaderText="Broker State" 
            SortExpression="BroState1" />
        <asp:BoundField DataField="Entity1" HeaderText="Entity Type" 
            SortExpression="Entity1" />
        <asp:BoundField DataField="Coverage" 
            HeaderText="Coverage" SortExpression="Coverage" 
            DataFormatString=" {0:c}" />
        <asp:BoundField DataField="Status1" HeaderText="Status" 
            SortExpression="Status1" />

        <asp:HyperLinkField DataNavigateUrlFields="SubmissionId" 
            DataNavigateUrlFormatString="View.aspx?SubmissionId={0}" Text="View" 
            HeaderText="View" />
        <asp:HyperLinkField DataNavigateUrlFields="SubmissionId" 
            DataNavigateUrlFormatString="ViewEdit.aspx?SubmissionId={0}" HeaderText="Edit" 
            Text="Edit" />

    </Columns>

</asp:GridView>

//And finally, the print method in the presentation layer that proves I’m not crazy:

 SubmissionService ss = new SubmissionService();
    List<Submission> SubmissionsList = ss.getAllSubmission();


    GridView2.DataSource = SubmissionsList;
    GridView2.DataBind();

    Submission tempsub = SubmissionsList.First();
    Response.Write("Printing temp:" + tempsub._Cust.CustName1 + " total count is:" + SubmissionsList.Count() );  // *This returns the correct data for whichever field I specify.*
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:29:59+00:00Added an answer on May 23, 2026 at 5:29 am

    Try look here:

    http://www.dailycode.info/Blog/post/2009/01/11/ASPNet-GridView-databinding-a-subobject.aspx

    The key in this post is to use a TemplateField with a label:

    <asp:TemplateField HeaderText="Stock location description">
     <ItemTemplate>
       <asp:Label ID="lblCRCID" runat="server"
        Text='<%# ((Namespace.TestStock)(Container.DataItem)).StockLocation.Description %>'>
       </asp:Label>
      </ItemTemplate>
    </asp:TemplateField>
    <asp:BoundField DataField="Description" HeaderText="Stock descrioption" />
    

    HTH

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I used javascript for loading a picture on my website depending on which small
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.