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

  • Home
  • SEARCH
  • 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 9150501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:37:10+00:00 2026-06-17T11:37:10+00:00

I want to display the values from column named total on a label in

  • 0

I want to display the values from column named “total” on a label in my
GridView footer.

The value of “total” column is same along every row so it does not matter which ever cell is chosen as long as we are in that column.

I am using a template-field for my column “total” and I am hiding it by making its visibility=false. so what i want is i want to display the value from my column named total on to a label which is inside my gridview

Here is the code sample I have tried, but its giving an error:

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
int total;
        if (e.Row.RowType == DataControlRowType.DataRow) 
        { 
            total = Convert.ToInt32(((DataRowView)e.Row.DataItem)["total"].ToString()); 
        } 
        if (e.Row.RowType == DataControlRowType.Footer) 
        { 
            Label lblamount7 = (Label)e.Row.FindControl("Label27"); 
            lblamount7.Text =total.ToString(); // use of unassigned local variable 'total'
        }
    }

this is the aspx of the hidden column
‘> ‘>

  • 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-17T11:37:11+00:00Added an answer on June 17, 2026 at 11:37 am

    For hiding the column take a Hiddeneeild in the Template-Field of GridView. The syntax will be like

    <asp:TemplateField>
    <ItemTemplate>
     <asp:HiddenField ID="HiddenField1" runat="server" Value='<%#Eval("Total") %>'/>
    
    
                            </ItemTemplate>
                            </asp:TemplateField> 
    

    Now to calculate total and show it in footer of GridView you can do like

    int total = 0;
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
    if(e.Row.RowType==DataControlRowType.DataRow)
    {
    total += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "Total"));
    }
    if(e.Row.RowType==DataControlRowType.Footer)
    {
    Label lblamount7 = (Label)e.Row.FindControl("lblTotal");
    lblamount7.Text = total.ToString();
    }
    }
    

    It will surely work. Good Luck and do comment if it worked.

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

Sidebar

Related Questions

I want to display the link if value of row is equal to GRAND
I want to display Alias name based on the value of some other column
i want to display values from a database (a list of categories) into a
I want to display three different values allocated to two different headers, in other
I want to display all the possible enum values as Radio buttons. I am
I want to display different forms in change_form depending on some model field's values.
I want to display digits with leading 0s, for values of a single digit,
I want to be able to display links based on cell values. So if
I have a report in which I want to display value of 2 engineers
Summary: I want to display a value (in a text box) stored in another

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.