Refer below code for your reference.
HTML
<asp:GridView ID="gvGridMarks" runat="server">
</asp:GridView>
<br />
<br />
<asp:GridView ID="gvGridMarkwithScore" runat="server">
</asp:GridView>
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("Id", typeof(int)));
dt.Columns.Add(new DataColumn("Name", typeof(string)));
dt.Columns.Add(new DataColumn("Maths", typeof(string)));
dt.Columns.Add(new DataColumn("Physics", typeof(string)));
dt.Columns.Add(new DataColumn("Chemistry", typeof(string)));
dt.Columns.Add(new DataColumn("Score", typeof(string)));
dt.Rows.Add(1, "xyz", "10", "2", "", "");
dt.Rows.Add(2, "abc", "8", "8", "8", "");
dt.Rows.Add(3, "def", "1", "", "", "");
gvGridMarks.DataSource = dt;
gvGridMarks.DataBind();
foreach (DataRow dr in dt.Rows)
{
if (!string.IsNullOrEmpty(Convert.ToString(dr["Maths"])) && !string.IsNullOrEmpty(Convert.ToString(dr["Physics"])) && !string.IsNullOrEmpty(Convert.ToString(dr["Chemistry"])))
{
double m1 = Convert.ToDouble(dr["Maths"]);
double m2 = Convert.ToDouble(dr["Physics"]);
double m3 = Convert.ToDouble(dr["Chemistry"]);
double totalscore = m1 + m2 + m3;
// Set the three values in the new table now.
int maximum = 30;
double total = Math.Round(((totalscore / maximum) * 100),2);
dr["Score"] = total;
}
}
gvGridMarkwithScore.DataSource = dt;
gvGridMarkwithScore.DataBind();
}
}