using ITemplate for my gridview help

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
 
A

Andy O'Neill

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");
}
}
 
R

rodchar

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

.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top