Hi,
I have a Datagrid and in Datagrid I am using five radiobutton(Excellent, Best, Good, Average, Inferior) and on textbox (total marks) and lable marks which showing marks. Now I want when I click any radiobutton my calculation getting into total marks. These total marks must be added in footer of datagrid for grandsum. I am tying on my running webform but it is not getting total of datagrid footer. Only showing ‘0’..
protected void dgDetails_ItemDataBound(object source, DataGridItemEventArgs e)
{
TextBox tbTotal;
try
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
MarksTotal += Convert.ToInt32(e.Item.Cells[2].Text);
tbTotal = (TextBox)e.Item.FindControl("tbTotal");
if (tbTotal.Text == string.Empty)
{
GrandTotal += 0;
}
else
{
GrandTotal = Convert.ToInt32(tbTotal.Text);
}
}
if (e.Item.ItemType == ListItemType.Footer)
{
e.Item.Cells[1].Text = "Total";
e.Item.Cells[2].Text = MarksTotal.ToString();
e.Item.Cells[9].Text = GrandTotal.ToString();
}
}
catch (Exception ex)
{
throw ex;
}
}
protected void rbExcellent_CheckedChanged(object sender, System.EventArgs e)
{
RadioButton rbExcel;
RadioButton rbBst;
RadioButton rbGd;
RadioButton rbAvg;
RadioButton rbInf;
int lMarks;
TextBox tbTot;
try
{
foreach (DataGridItem item in this.dgDetails.Items)
{
rbExcel = (RadioButton)item.FindControl("rbExcellent");
rbBst = (RadioButton)item.FindControl("rbBest");
rbGd = (RadioButton)item.FindControl("rbGood");
rbAvg = (RadioButton)item.FindControl("rbAverage");
rbInf = (RadioButton)item.FindControl("rbInferior");
lMarks = Convert.ToInt32(item.Cells[2].Text);
tbTot = (TextBox)item.FindControl("tbTotal");
if (rbExcel.Checked == true)
{
tbTot.Text = Convert.ToString((lMarks * 100) / 100);
rbBst.Checked = false;
rbGd.Checked = false;
rbAvg.Checked = false;
rbInf.Checked = false;
}
}
}
catch (Exception ex)
{
throw ex;
}
}