Karthik_Mahalingam
попробовать это
<asp:GridView ID="GridView1" HeaderStyle-BackColor="#3AC0F2" HeaderStyle-ForeColor="White"
runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Sr" HeaderText="Id" />
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:BoundField DataField="D1" HeaderText="D1" />
<asp:BoundField DataField="D2" HeaderText="D2" />
<asp:BoundField DataField="D3" HeaderText="D3" />
<asp:BoundField DataField="D4" HeaderText="D4" />
<asp:BoundField DataField="D5" HeaderText="D5" />
<asp:BoundField DataField="D6" HeaderText="D6" />
<asp:BoundField DataField="D7" HeaderText="D7" />
<asp:BoundField DataField="L" HeaderText="L" />
<asp:BoundField DataField="A" HeaderText="A" />
</Columns>
</asp:GridView>
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.Add("Sr");
dt.Columns.Add("Name");
dt.Columns.Add("D1");
dt.Columns.Add("D2");
dt.Columns.Add("D3");
dt.Columns.Add("D4");
dt.Columns.Add("D5");
dt.Columns.Add("D6");
dt.Columns.Add("D7");
dt.Columns.Add("L");
dt.Columns.Add("A");
dt.Rows.Add(1,"Name1","P","P","P","L","A","A","P");
dt.Rows.Add(1, "Name2", "L", "L", "P", "P", "A", "A", "A");
DataTable dtFinal = dt.Clone();
foreach (DataRow row in dt.Rows)
{
int l = 0, a = 0, p = 0;
var aray = new string[]{"D1","D2","D3","D4","D5","D6","D7"};
foreach (var col in aray)
{
if (Convert.ToString(row[col]) == "L")
l++;
if (Convert.ToString(row[col]) == "P")
p++;
if (Convert.ToString(row[col]) == "A")
a++;
}
row["L"] = l.ToString();
row["A"] = a.ToString();
}
GridView1.DataSource = dt;
GridView1.DataBind();
}
}