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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:57:32+00:00 2026-05-18T06:57:32+00:00

How do you call a codebehind/class method from a gridview in an aspx page?

  • 0

How do you call a codebehind/class method from a gridview in an aspx page? Also, I need to pass the value of databound column to that method. Is this possible?

Something like this:

<asp:BoundField DataField="Precision" />
<asp:BoundField DataField="MyNumber" DataFormatString="FormatHelper.Format(MyNumber, Precision)" />
  • 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-18T06:57:33+00:00Added an answer on May 18, 2026 at 6:57 am

    Edit: I tested this to work.

    <asp:TemplateField HeaderText="My Number">
      <ItemTemplate>
    
            <asp:Label runat="server" 
               Text='<%# Eval("MyNumber", FormatHelper.Format((decimal)Eval("MyNumber"), (decimal)Eval("Precision") )) %>' />
    
      </ItemTemplate>
    </asp:TemplateField>
    

    This works because the Eval method takes the DataFormatString as an optional second parameter. note: Make sure you replace the casts with the appropriate types for the method signature.

    An easier way might be to bind to a linq-to-objects projection instead.

    myGridView.DataBind( from foo in fooList
                         select new {
                           MyNumber = MyNumber,
                           Precision = Precision,
                           MyFormattedNumber = FormatHelper.Format(MyNumber, Precision),
                         } );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the difference between calling Response.Redirect from the codebehind of a page, versus
Newb here. I am instantiating the class below from a Silverlight page's code-behind. I
I am trying to setup an ASPX page to call a WCF servcie thorugh
I have a simple function that I want to call in the code behind
I need to call into a Win32 API to get a series of strings,
How do I call shell commands from inside of a Ruby program? How do
If I call finalize() on an object from my program code, will the JVM
I have an ASP.NET 3.5 GridView on a WebForm. The GridView gets data from
This is a common need I have on every page: if (session[LoggedIn] == null
I am trying to call a storyboard declared in xaml from c#. <UserControl.Resources> <Storyboard

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.