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();
}