469,268 Members | 1,019 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,268 developers. It's quick & easy.

Computed columns in datagrid

Hi,

Can I have computed columns in a datagrid? If yes, how?

TIA
Nov 18 '05 #1
3 1808
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

"Raymond Du" <rd**@yahoo.com> wrote in message
news:uL**************@TK2MSFTNGP15.phx.gbl...
Hi,

Can I have computed columns in a datagrid? If yes, how?

TIA

Nov 18 '05 #2
The data table have a compute() method that you can do this. Check this
article out
http://aspnet.4guysfromrolla.com/articles/082003-1.aspx

"Raymond Du" wrote:
Hi,

Can I have computed columns in a datagrid? If yes, how?

TIA

Nov 18 '05 #3
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.
--
Joe Fallon
"Raymond Du" <rd**@yahoo.com> wrote in message
news:uL**************@TK2MSFTNGP15.phx.gbl...
Hi,

Can I have computed columns in a datagrid? If yes, how?

TIA

Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Paulo Andre Ortega Ribeiro | last post: by
4 posts views Thread by Henning N?rg?rd | last post: by
5 posts views Thread by Jay Villa | last post: by
reply views Thread by am72de | last post: by
7 posts views Thread by Aamir Mahmood | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.