By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,189 Members | 1,559 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,189 IT Pros & Developers. It's quick & easy.

Computed columns in datagrid

P: n/a
Hi,

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

TIA
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.