ado.net unbound totals column

G

Greg

I was wondering if there is a simple way to present a totals column in
a bound datagrid where the totals aren't actually persisted (in my case
to an xml file). Ideally, when I populate the datagrid using the
dataview, I would like to add values to an unbound totals column.

What is the best way to do this? Perhaps the dataview should contain a
totals column, and this is bound, but the dataset itself doesn't. That
way, the totals data woudnt be persisted.

This must be such an every day thing to need to do, I'm surprised I
haven't found anything yet by googling.

Any tips would be greatly appreciated!

Greg.
 
G

Galcho[MCSD.NET]

subscribe to RowDataBound or ItemCreated event of GridView
here is sample code for RowDataBound event

protected void gridTasks_RowDataBound(object sender,
GridViewRowEventArgs e)
{
switch (e.Row.RowType) {
case DataControlRowType.DataRow:

case DataControlRowType.Footer:
if (SQLDataAccessLayer.TaskFilterBy.VersionTasks !=
Mode) {
e.Row.Cells[3].Text = "Total tasks: ";
e.Row.Cells[4].Text =
((DataTable)gridTasks.DataSource).DefaultView.Count.ToString();
} else {
e.Row.Cells[5].Text = "Total tasks: ";
e.Row.Cells[6].Text =
((DataTable)gridTasks.DataSource).DefaultView.Count.ToString();
}
break;
}
}

hope this helps
Galin Iliev[MCSD.NET]
www.galcho.com
 

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

Top