using ITemplate for my gridview help

  • Thread starter Thread starter rodchar
  • Start date Start date
R

rodchar

Hi All,

As in the subject, I'm using ITemplate class for my GridView in ASP.NET
Fx2.0 VS2005.

It's a 3 column GridView (FirstName, LastName, TotalAmount)

How do I add the Footer dynamically for TotalAmount column and then attach
to total sum field to it all using dynamic columns for my gridview?

Thanks,
rodchar
 
rodchar said:
Hi All,

As in the subject, I'm using ITemplate class for my GridView in ASP.NET
Fx2.0 VS2005.

It's a 3 column GridView (FirstName, LastName, TotalAmount)

How do I add the Footer dynamically for TotalAmount column and then attach
to total sum field to it all using dynamic columns for my gridview?

Thanks,
rodchar

I understand gridviews in asp.net and have used them extensively.
I don't understand what you mean by ITemplate.

The thing to do is to turn the footer on and handle rowdatabound, this code
does totalling for a gridview.
I've hacked it about a bit so it's not obvious which system it's out of.

protected void gv_RowDataBound(object sender, GridViewRowEventArgs
e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Total_X += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem,
"X"));
Total_Y += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem,
"Y"));
Total_Z += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem,
"Z"));
}
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[3].Text =
Total_X.ToString("###,###,###,###.00");
e.Row.Cells[4].Text =
Total_Y.ToString("###,###,###,###.00");
e.Row.Cells[5].Text = Total_ZToString("###,###,###,###.00");
}
}
 
Found answer here:
http://msdn.microsoft.com/en-us/magazine/cc301573.aspx

Andy O'Neill said:
rodchar said:
Hi All,

As in the subject, I'm using ITemplate class for my GridView in ASP.NET
Fx2.0 VS2005.

It's a 3 column GridView (FirstName, LastName, TotalAmount)

How do I add the Footer dynamically for TotalAmount column and then attach
to total sum field to it all using dynamic columns for my gridview?

Thanks,
rodchar

I understand gridviews in asp.net and have used them extensively.
I don't understand what you mean by ITemplate.

The thing to do is to turn the footer on and handle rowdatabound, this code
does totalling for a gridview.
I've hacked it about a bit so it's not obvious which system it's out of.

protected void gv_RowDataBound(object sender, GridViewRowEventArgs
e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Total_X += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem,
"X"));
Total_Y += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem,
"Y"));
Total_Z += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem,
"Z"));
}
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[3].Text =
Total_X.ToString("###,###,###,###.00");
e.Row.Cells[4].Text =
Total_Y.ToString("###,###,###,###.00");
e.Row.Cells[5].Text = Total_ZToString("###,###,###,###.00");
}
}

.
 
Back
Top