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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:45:07+00:00 2026-06-02T01:45:07+00:00

I have a GridView that gets a DataSource. Now on RowDataBound, I need to

  • 0

I have a GridView that gets a DataSource. Now on RowDataBound, I need to make a couple changes to the row cells, but I need an outside piece of information to determine what change occurs.

static void GridRowDataBoundProbables(object sender, GridViewRowEventArgs e)
{
    if(e.Row.RowType == DataControlRowType.Header)
    {
        foreach (TableCell cell in e.Row.Cells)
        {
            if (!int.TryParse(cell.Text, out postNum)) continue;
            cell.CssClass += " postCell";
            cell.Add(new Panel { CssClass = (**isHarness** ? PostHarness : PostThoroughbred) + postNum });
            cell.Add(new Label { Text = postNum.ToString() });
        }
    }
}

I need the isHarness bool, which is available when I create and bind the grid.
Also since the grid is created during a static WebMethod call I can’t make it a global on the page.

How can I get the value of isHarness into this function? I thought I could create my own EventArgs that inherit from GridViewRowEventArgs but i still dont know how to actually get the bool in my new args…

Edit

isHarness is a bool determined at time that the DataSource is created, but is not a part of the DataSource

Below is a mock of the outer call:

[WebMethod]
public static AjaxReturnObject GetProbables(string token, string track, string race, string pool)
{
    Tote tote = new Tote(...);
    GridView grid = new GridView();
    grid.RowDataBound += GridRowDataBound;
    grid.DataSource = tote.GetDataSource(); //isHarness is available during creation of DataSource
    //Here tote.isHarness is available from property
    grid.DataBind();
}
  • 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-02T01:45:09+00:00Added an answer on June 2, 2026 at 1:45 am

    The answer, as always, is “it depends”.

    We don’t know much about your bool isHarness. What is the scope of this variable? Is it a member of the page? A member of the GridView? Is it part of the GridView’s datasource?

    If it is a public member of the page, from your method you could cast sender to a web control, and then traverse the parent hierarchy until you find the Page, and get it from there.

    If it is a member of the GridView, just do the same and traverse the parent structure until you find the GridView.

    EDIT

    Thanks for posting more source. It looks like isHarness is a member of the tote object. If that’s the case, you probably cannot get it in your DataBound event. tote is only a local variable, and it is out of scope and long gone by that point. You probably need to store that value elsewhere if you want to access it in your GridRowDataBound code.

    For example, you could extend GridView into a custom class that has an IsHarness property, and set that value in your GetProbables function. Then you could access it in your GridRowDataBound event by casting sender appropriately.

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

Sidebar

Related Questions

i have a gridview that creates a new row with a new gridview in
I have a gridview that is using a LinqDataSource for it's datasource. I've added
I have a GridView that I need to dynamically add TemplateField elements to. My
I have a gridview that is bound to a datasource on a Windows Form
I have a gridview that is bound to a datasource (Windows Forms, VB.NET). One
I have a gridview setup that gets its data from a SQL database stored
I have a gridview that gets created in codebehind. In the below code, I
I have a GridView that gets it's data from the SQL database . I
I have a gridview on my page that gets bound to user search results.
I basically have an entity that gets bound to my gridview and has a

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.