Computed columns in datagrid

M

mortb

one way:

add a column
insert values in it in the event ItemDatabound

example column three is your computed value column:

private void _Grid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)

{

if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)

{

e.Item.Cells[3].Text = "your computed value";

}

}

cheers,
mortb
 
J

Joe Fallon

A 3rd idea would be to do the computation in your data source.
e.g if it is a custom collection then add a readonly property to the
contained child class and have it return the computation. Then you can treat
it as a bound column in the grid.
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top