Monday, March 26, 2012

Performing calcualtions on data in gridview

Is it possible to perform calculations on data in your gridview in your
ASP, or do you need to do any calculations in the OnRowDataBound event?
Here is what I am trying to do :
<asp:TemplateField HeaderText="Target (%)"
SortExpression="TargetPercentage">
<ItemTemplate>
<asp:Label ID="lblTargetPercentage"
Text='<%# Eval("TargetPercentage")*100 %>' runat="server"></asp:Label>
</ItemTemplate>
<ItemStyle Height="24px" Width="50px" />
*** Sent via Developersdex http://www.examnotes.net ***I would make the calculation part of the sql statement or part of the stored
procedure so that the gridview simply displays the
calculated results
"Mike P" <mike.parr@.gmail.com> wrote in message news:OrfJwbIlGHA.408@.TK2MSFTNGP03.phx.gbl..
.
> Is it possible to perform calculations on data in your gridview in your
> ASP, or do you need to do any calculations in the OnRowDataBound event?
> Here is what I am trying to do :
> <asp:TemplateField HeaderText="Target (%)"
> SortExpression="TargetPercentage">
> <ItemTemplate>
> <asp:Label ID="lblTargetPercentage"
> Text='<%# Eval("TargetPercentage")*100 %>' runat="server"></asp:Label>
> </ItemTemplate>
> <ItemStyle Height="24px" Width="50px" />
>
> *** Sent via Developersdex http://www.examnotes.net ***
If the calculations required input that was not available within the
database, you could retrieve the dataset with a constant value column
and then perform the calculation on the dataset before binding to the
datagrid.
Jon Paal wrote:
> I would make the calculation part of the sql statement or part of the stor
ed procedure so that the gridview simply displays the
> calculated results
>
> "Mike P" <mike.parr@.gmail.com> wrote in message news:OrfJwbIlGHA.408@.TK2MS
FTNGP03.phx.gbl...

0 comments:

Post a Comment