|
|
|
start date: Mon, 20 Aug 2007 18:23:09 -0400,
posted on: microsoft.public.dotnet.framework.aspnet.datagridcontrol
back
| Thread Index |
|
1
Nathan Sokalski
|
|
2
Alvin Bruney [MVP] some guy without an email address
|
|
3
Alvin Bruney [MVP] some guy without an email address
|
|
4
Alvin Bruney [MVP] some guy without an email address
|
|
5
Nathan Sokalski
|
|
6
Nathan Sokalski
|
|
7
Nathan Sokalski
|
|
8
unknown
|
|
9
unknown
|
|
10
unknown
|
|
11
Nathan Sokalski
|
|
12
Nathan Sokalski
|
|
13
Nathan Sokalski
|
Inline Calculations for Databinding
I have two fields in the Datatable that I am using as my DataSource that I
need to multiply together before displaying them. Here is the databinding
expressions from my ASPX file to display the fields separately:
'<%# Databinder.Eval(Container.DataItem,"price","{0:C}") %>'
'<%# Databinder.Eval(Container.DataItem,"quantity","{0:D}") %>'
These are obviously both numeric values, but because my DataTable is not
created from a database, I cannot add an extra field by modifying my SQL
statement. Is there a way to somehow include an expression in the
databinding expression that multiplies the two values together? The only
alternative that I can think of is to use the ItemDataBound event and
manually assign the product of the two values to the desired control, but
because this requires using CType and FindControl, it is rather inefficient.
Any other ideas? Thanks.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/
Date:Mon, 20 Aug 2007 18:23:09 -0400
Author:
|
Re: Inline Calculations for Databinding
Why post this to so many groups, it's not necessary at all. In any case, you
will need CType, you won't necessarily need FindControl. If you know the
column, you can use the appropriate index to the cell.
--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET - MS Press
Professional VSTO 2005 - Wrox/Wiley
OWC Black Book www.lulu.com/owc
"Nathan Sokalski" wrote in message
news:uNdcti34HHA.5852@TK2MSFTNGP02.phx.gbl...
>I have two fields in the Datatable that I am using as my DataSource that I
>need to multiply together before displaying them. Here is the databinding
>expressions from my ASPX file to display the fields separately:
>
> '<%# Databinder.Eval(Container.DataItem,"price","{0:C}") %>'
> '<%# Databinder.Eval(Container.DataItem,"quantity","{0:D}") %>'
>
> These are obviously both numeric values, but because my DataTable is not
> created from a database, I cannot add an extra field by modifying my SQL
> statement. Is there a way to somehow include an expression in the
> databinding expression that multiplies the two values together? The only
> alternative that I can think of is to use the ItemDataBound event and
> manually assign the product of the two values to the desired control, but
> because this requires using CType and FindControl, it is rather
> inefficient. Any other ideas? Thanks.
> --
> Nathan Sokalski
> njsokalski@hotmail.com
> http://www.nathansokalski.com/
>
Date:Mon, 20 Aug 2007 20:18:13 -0400
Author:
|
Re: Inline Calculations for Databinding
Why post this to so many groups, it's not necessary at all. In any case, you
will need CType, you won't necessarily need FindControl. If you know the
column, you can use the appropriate index to the cell.
--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET - MS Press
Professional VSTO 2005 - Wrox/Wiley
OWC Black Book www.lulu.com/owc
"Nathan Sokalski" wrote in message
news:uNdcti34HHA.5852@TK2MSFTNGP02.phx.gbl...
>I have two fields in the Datatable that I am using as my DataSource that I
>need to multiply together before displaying them. Here is the databinding
>expressions from my ASPX file to display the fields separately:
>
> '<%# Databinder.Eval(Container.DataItem,"price","{0:C}") %>'
> '<%# Databinder.Eval(Container.DataItem,"quantity","{0:D}") %>'
>
> These are obviously both numeric values, but because my DataTable is not
> created from a database, I cannot add an extra field by modifying my SQL
> statement. Is there a way to somehow include an expression in the
> databinding expression that multiplies the two values together? The only
> alternative that I can think of is to use the ItemDataBound event and
> manually assign the product of the two values to the desired control, but
> because this requires using CType and FindControl, it is rather
> inefficient. Any other ideas? Thanks.
> --
> Nathan Sokalski
> njsokalski@hotmail.com
> http://www.nathansokalski.com/
>
Date:Mon, 20 Aug 2007 20:18:13 -0400
Author:
|
Re: Inline Calculations for Databinding
Why post this to so many groups, it's not necessary at all. In any case, you
will need CType, you won't necessarily need FindControl. If you know the
column, you can use the appropriate index to the cell.
--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET - MS Press
Professional VSTO 2005 - Wrox/Wiley
OWC Black Book www.lulu.com/owc
"Nathan Sokalski" wrote in message
news:uNdcti34HHA.5852@TK2MSFTNGP02.phx.gbl...
>I have two fields in the Datatable that I am using as my DataSource that I
>need to multiply together before displaying them. Here is the databinding
>expressions from my ASPX file to display the fields separately:
>
> '<%# Databinder.Eval(Container.DataItem,"price","{0:C}") %>'
> '<%# Databinder.Eval(Container.DataItem,"quantity","{0:D}") %>'
>
> These are obviously both numeric values, but because my DataTable is not
> created from a database, I cannot add an extra field by modifying my SQL
> statement. Is there a way to somehow include an expression in the
> databinding expression that multiplies the two values together? The only
> alternative that I can think of is to use the ItemDataBound event and
> manually assign the product of the two values to the desired control, but
> because this requires using CType and FindControl, it is rather
> inefficient. Any other ideas? Thanks.
> --
> Nathan Sokalski
> njsokalski@hotmail.com
> http://www.nathansokalski.com/
>
Date:Mon, 20 Aug 2007 20:18:13 -0400
Author:
|
Re: Inline Calculations for Databinding
How can I do it without FindControl? The place I would be using FindControl
would be when assigning the value to the control, like in the following:
CType(e.Item.FindControl("lblTotal"), Label).Text = "$" &
CStr(CSng(e.Item.DataItem("price")) * CInt(e.Item.DataItem("quantity")))
I realize that I could use the Controls property of e.Item, but that can
sometimes be hard to determine, and if I were to add or remove controls that
are above this control, the index would change. Were you talking about a
different technique? If so, could you give me an example? Thanks.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/
"Alvin Bruney [MVP]" <some guy without an email address> wrote in message
news:ez7QMj44HHA.5724@TK2MSFTNGP05.phx.gbl...
> Why post this to so many groups, it's not necessary at all. In any case,
> you will need CType, you won't necessarily need FindControl. If you know
> the column, you can use the appropriate index to the cell.
>
> --
> Regards,
> Alvin Bruney
> ------------------------------------------------------
> Shameless author plug
> Excel Services for .NET - MS Press
> Professional VSTO 2005 - Wrox/Wiley
> OWC Black Book www.lulu.com/owc
>
> "Nathan Sokalski" wrote in message
> news:uNdcti34HHA.5852@TK2MSFTNGP02.phx.gbl...
>>I have two fields in the Datatable that I am using as my DataSource that I
>>need to multiply together before displaying them. Here is the databinding
>>expressions from my ASPX file to display the fields separately:
>>
>> '<%# Databinder.Eval(Container.DataItem,"price","{0:C}") %>'
>> '<%# Databinder.Eval(Container.DataItem,"quantity","{0:D}") %>'
>>
>> These are obviously both numeric values, but because my DataTable is not
>> created from a database, I cannot add an extra field by modifying my SQL
>> statement. Is there a way to somehow include an expression in the
>> databinding expression that multiplies the two values together? The only
>> alternative that I can think of is to use the ItemDataBound event and
>> manually assign the product of the two values to the desired control, but
>> because this requires using CType and FindControl, it is rather
>> inefficient. Any other ideas? Thanks.
>> --
>> Nathan Sokalski
>> njsokalski@hotmail.com
>> http://www.nathansokalski.com/
>>
>
>
Date:Mon, 20 Aug 2007 21:09:53 -0400
Author:
|
Re: Inline Calculations for Databinding
How can I do it without FindControl? The place I would be using FindControl
would be when assigning the value to the control, like in the following:
CType(e.Item.FindControl("lblTotal"), Label).Text = "$" &
CStr(CSng(e.Item.DataItem("price")) * CInt(e.Item.DataItem("quantity")))
I realize that I could use the Controls property of e.Item, but that can
sometimes be hard to determine, and if I were to add or remove controls that
are above this control, the index would change. Were you talking about a
different technique? If so, could you give me an example? Thanks.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/
"Alvin Bruney [MVP]" <some guy without an email address> wrote in message
news:ez7QMj44HHA.5724@TK2MSFTNGP05.phx.gbl...
> Why post this to so many groups, it's not necessary at all. In any case,
> you will need CType, you won't necessarily need FindControl. If you know
> the column, you can use the appropriate index to the cell.
>
> --
> Regards,
> Alvin Bruney
> ------------------------------------------------------
> Shameless author plug
> Excel Services for .NET - MS Press
> Professional VSTO 2005 - Wrox/Wiley
> OWC Black Book www.lulu.com/owc
>
> "Nathan Sokalski" wrote in message
> news:uNdcti34HHA.5852@TK2MSFTNGP02.phx.gbl...
>>I have two fields in the Datatable that I am using as my DataSource that I
>>need to multiply together before displaying them. Here is the databinding
>>expressions from my ASPX file to display the fields separately:
>>
>> '<%# Databinder.Eval(Container.DataItem,"price","{0:C}") %>'
>> '<%# Databinder.Eval(Container.DataItem,"quantity","{0:D}") %>'
>>
>> These are obviously both numeric values, but because my DataTable is not
>> created from a database, I cannot add an extra field by modifying my SQL
>> statement. Is there a way to somehow include an expression in the
>> databinding expression that multiplies the two values together? The only
>> alternative that I can think of is to use the ItemDataBound event and
>> manually assign the product of the two values to the desired control, but
>> because this requires using CType and FindControl, it is rather
>> inefficient. Any other ideas? Thanks.
>> --
>> Nathan Sokalski
>> njsokalski@hotmail.com
>> http://www.nathansokalski.com/
>>
>
>
Date:Mon, 20 Aug 2007 21:09:53 -0400
Author:
|
Re: Inline Calculations for Databinding
How can I do it without FindControl? The place I would be using FindControl
would be when assigning the value to the control, like in the following:
CType(e.Item.FindControl("lblTotal"), Label).Text = "$" &
CStr(CSng(e.Item.DataItem("price")) * CInt(e.Item.DataItem("quantity")))
I realize that I could use the Controls property of e.Item, but that can
sometimes be hard to determine, and if I were to add or remove controls that
are above this control, the index would change. Were you talking about a
different technique? If so, could you give me an example? Thanks.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/
"Alvin Bruney [MVP]" <some guy without an email address> wrote in message
news:ez7QMj44HHA.5724@TK2MSFTNGP05.phx.gbl...
> Why post this to so many groups, it's not necessary at all. In any case,
> you will need CType, you won't necessarily need FindControl. If you know
> the column, you can use the appropriate index to the cell.
>
> --
> Regards,
> Alvin Bruney
> ------------------------------------------------------
> Shameless author plug
> Excel Services for .NET - MS Press
> Professional VSTO 2005 - Wrox/Wiley
> OWC Black Book www.lulu.com/owc
>
> "Nathan Sokalski" wrote in message
> news:uNdcti34HHA.5852@TK2MSFTNGP02.phx.gbl...
>>I have two fields in the Datatable that I am using as my DataSource that I
>>need to multiply together before displaying them. Here is the databinding
>>expressions from my ASPX file to display the fields separately:
>>
>> '<%# Databinder.Eval(Container.DataItem,"price","{0:C}") %>'
>> '<%# Databinder.Eval(Container.DataItem,"quantity","{0:D}") %>'
>>
>> These are obviously both numeric values, but because my DataTable is not
>> created from a database, I cannot add an extra field by modifying my SQL
>> statement. Is there a way to somehow include an expression in the
>> databinding expression that multiplies the two values together? The only
>> alternative that I can think of is to use the ItemDataBound event and
>> manually assign the product of the two values to the desired control, but
>> because this requires using CType and FindControl, it is rather
>> inefficient. Any other ideas? Thanks.
>> --
>> Nathan Sokalski
>> njsokalski@hotmail.com
>> http://www.nathansokalski.com/
>>
>
>
Date:Mon, 20 Aug 2007 21:09:53 -0400
Author:
|
Re: Inline Calculations for Databinding
How do you create your DataTable? It would seem easier to me to just
create another column at the same time and add both the values
together.
Date:Tue, 21 Aug 2007 09:14:47 -0000
Author:
|
Re: Inline Calculations for Databinding
How do you create your DataTable? It would seem easier to me to just
create another column at the same time and add both the values
together.
Date:Tue, 21 Aug 2007 09:14:47 -0000
Author:
|
Re: Inline Calculations for Databinding
How do you create your DataTable? It would seem easier to me to just
create another column at the same time and add both the values
together.
Date:Tue, 21 Aug 2007 09:14:47 -0000
Author:
|
Re: Inline Calculations for Databinding
I create my DataTable manually by adding DataColumns to a DataTable and then
adding data using the DataTable's Rows.Add method. The reason I would prefer
not to create an extra column is because I have to store the DataTable in
ViewState, which, even though I will rarely have more than about 10 or so
records in the DataTable, it can increase the size of the client's download,
as well as require me to update more fields. If I could do the
multiplication inline, it would allow me to have only one extra area in my
code that is different, and would not increase the size of the client's
download.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/
"ca8msm@aspnetlibrary.com" wrote in message
news:1187687687.952550.63790@k79g2000hse.googlegroups.com...
> How do you create your DataTable? It would seem easier to me to just
> create another column at the same time and add both the values
> together.
>
Date:Tue, 21 Aug 2007 20:49:47 -0400
Author:
|
Re: Inline Calculations for Databinding
I create my DataTable manually by adding DataColumns to a DataTable and then
adding data using the DataTable's Rows.Add method. The reason I would prefer
not to create an extra column is because I have to store the DataTable in
ViewState, which, even though I will rarely have more than about 10 or so
records in the DataTable, it can increase the size of the client's download,
as well as require me to update more fields. If I could do the
multiplication inline, it would allow me to have only one extra area in my
code that is different, and would not increase the size of the client's
download.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/
"ca8msm@aspnetlibrary.com" wrote in message
news:1187687687.952550.63790@k79g2000hse.googlegroups.com...
> How do you create your DataTable? It would seem easier to me to just
> create another column at the same time and add both the values
> together.
>
Date:Tue, 21 Aug 2007 20:49:47 -0400
Author:
|
Re: Inline Calculations for Databinding
I create my DataTable manually by adding DataColumns to a DataTable and then
adding data using the DataTable's Rows.Add method. The reason I would prefer
not to create an extra column is because I have to store the DataTable in
ViewState, which, even though I will rarely have more than about 10 or so
records in the DataTable, it can increase the size of the client's download,
as well as require me to update more fields. If I could do the
multiplication inline, it would allow me to have only one extra area in my
code that is different, and would not increase the size of the client's
download.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/
"ca8msm@aspnetlibrary.com" wrote in message
news:1187687687.952550.63790@k79g2000hse.googlegroups.com...
> How do you create your DataTable? It would seem easier to me to just
> create another column at the same time and add both the values
> together.
>
Date:Tue, 21 Aug 2007 20:49:47 -0400
Author:
|
|
|