views:

34

answers:

1

I need to able to display the results from a seperate query in the footer of a gridview.

What is the best way to go about this?

I did some google searches and what I found pretty much revolves using the original datasource and doing something like addition to display the information in the footer. However I really need to be able to display this single line of information from a seperate query.

Any direction given would be appreciated. Links, tips, tricks, etc.

Thanks.

A: 

So I was able to figure it out.

I created a rowdatabound event handler, had an if statement check to see that the event handler is at the footer and then process my code.

Example:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.Footer)
    {
      // Connect
      // Build query
      // Execute data reader
      // Bind data
      e.Row.Cells[0].Text = reader["somedata"].ToString();
      e.Row.Cells[1].Text = reader["someotherdata"].ToString();
      // Close reader and connection
     }
}
Mike Keller