HI Try this sample code..
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack) { }
else
{
DataTable dt = new DataTable();
dt.Columns.Add("FREE_THROW_MADE", typeof(double));
dt.Columns.Add("FREE_THROW_ATTEMPT", typeof(double));
dt.Rows.Add(1, 2);
dt.Rows.Add(2, 4);
GridViewHomeTeamStats.DataSource = dt;
GridViewHomeTeamStats.DataBind();
}
}
double avg = 0;
int count = 0;
protected void GridViewHomeTeamStats_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow) {
count++;
var text = (e.Row.FindControl("Label1") as Label).Text.Trim();
if (text.Contains(@"/"))
{
var arytemp = text.Split('/');
if (arytemp.Length == 2)
{
double FREE_THROW_MADE = Convert.ToDouble( arytemp[0]);
double FREE_THROW_ATTEMPT = Convert.ToDouble(arytemp[1]);
avg += (FREE_THROW_MADE / FREE_THROW_ATTEMPT);
}
}
}
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].Text = string.Format("{0} %", (avg * 100)/count);
}
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="jquery.js.js"></script>
<script type="text/javascript">
var openchild = function () {
window.open('childpage.aspx', 'popup_window', 'width=300,height=100,left=100,top=100,resizable=yes');
return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView ID="GridViewHomeTeamStats" runat="server" AutoGenerateColumns="False" ShowFooter="True" OnRowDataBound="GridViewHomeTeamStats_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="FT" SortExpression="FREE_THROW_MADE">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("FREE_THROW_MADE") + "/" + Eval("FREE_THROW_ATTEMPT") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</form>
</body>
</html>