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 8086307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:24:22+00:00 2026-06-05T18:24:22+00:00

I am working with three tables in a db. The first table is labeled

  • 0

I am working with three tables in a db. The first table is labeled ‘Accounts’ and has a one-many relationship with the second, ‘AccountItems’.The AccountItems table has a size column. The third table, somewhat tangential to this question, is ‘Customer’ which has many accounts.

I am Creating a RadGrid that is bound to the Account table. It should look something like this:

Customer | Location | Account# | Total Size
___________________________________________

Location and Account # are easy, as was Customer because the navigation property worked in an item template.

My problem however, is the Size column. It should total the Size from each AccountItem. Example, if there are four AccountItems with a size of ’50’ each, then the total should be 200. It does not seem like I can simply navigate the child relationship in an Eval() like I did for the Customer. Is it possible to do this in the column code, or do I need to do a server side event handler for OnItemCreated?

Edit

I figured it out for a temp fix.

<ItemTemplate>
    <asp:Label ID="lblSizeSum" runat="server"Text='<%# CalculateSizeTotal((MS_Accounts)Container.DataItem)%>'>
<ItemTemplate>

And then the code behind:

Protected string CalculateSizeTotal(MS_Accounts dataItem)
    {
        return dataItem.MS_AccountLoads.Sum(s => s.Size).ToString();

    }

The only thing I don’t like about this is the clear violation of MVC by accessing my ORM directly for the casting.

  • 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-06-05T18:24:24+00:00Added an answer on June 5, 2026 at 6:24 pm

    Please check below code snippet.
    Let me know if i am missing any thing or not understand your requirement.

    .aspx

      <telerik:RadGrid ID="RadGrid2" runat="server" AllowPaging="True" AllowSorting="True"
            OnNeedDataSource="RadGrid2_NeedDataSource" AutoGenerateColumns="False" 
            onitemdatabound="RadGrid2_ItemDataBound">
            <MasterTableView>
                <Columns>
                    <telerik:GridBoundColumn DataField="CustomerID" HeaderText="CustomerID" UniqueName="CustomerID">
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn>
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" ></asp:Label>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
            </MasterTableView>
    
        </telerik:RadGrid>
    

    .aspx.cs

    public partial class forumpage : System.Web.UI.Page
    {

    protected void RadGrid2_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
    RadGrid2.DataSource = getDatarofGrid();
    }

    protected List<Customer> getDatarofGrid()
    {
        List<Customer> lstCustomer = new List<Customer>();
        Customer customer;
    
        for (int i = 0; i < 3; i++)
        {
            customer = new Customer();
            customer.CustomerID = i;
    
            List<Sizes> lstSize = new List<Sizes>();
            Sizes sizes;
            for (int j = 0; j < 3; j++)
            {
                sizes = new Sizes();
                sizes.size = i + 100;
                lstSize.Add(sizes);
            }
    
            customer.sizes = lstSize;
            lstCustomer.Add(customer);
        }
    
    
    
        return lstCustomer;
    }
    protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
            Label Label1 = item.FindControl("Label1") as Label;
    
            Customer objcustomer = item.DataItem as Customer;
    
            if (objcustomer != null && objcustomer.sizes.Count > 0)
            {
               Label1.Text =  objcustomer.sizes.Sum(i => i.size).ToString();
            }
        }
    }
    

    }

    public class Customer
    {
    public int CustomerID { get; set; }
    public List sizes { get; set; }
    }

    public class Sizes
    {
    public int size { get; set; }
    }

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

Sidebar

Related Questions

I am working on a program that uses two tables. The first table has
I have three tables in my database. First table is Employee : Second table
I'm working with three tables, and for simplicity's sake let's call them table A,
Here's some background info. I have three MySQL tables (all InnoDB). The first table
I am trying to join three tables. The first is a table of groups,
After three years working on a C++ project, the executable has grown to 4
I am working with your typical three layered application that has a presentation layer,
We have three developers and one tester all working against the same database. We
This is for an upcoming project. I have two tables - first one keeps
I have the following tables in Oracle 11g: Table A SITE_ID SITE_NAME VECTOR .........MANY

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.