Performing calcualtions on data in gridview

M

Mike P

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" />
 
J

Jon Paal

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
 
G

Greg

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.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top