Sunday, 22 July 2012

calculating amount based on mutuallay exclusive radio buttons for gridview

   for (int i = 0; i < gvConsolidatedReport1.Rows.Count; i++)
                        {

                            RadioButtonList rbPCRC = (RadioButtonList)gvConsolidatedReport1.Rows[i].FindControl("sdf");
                            if (rbPCRC.SelectedValue == "PC")
                            {
                                dr = receipt.NewRow();

                                subjects += "PC@" + gvConsolidatedReport1.Rows[i].Cells[1].Text + ",";
                                subjectnames += "PC@" + gvConsolidatedReport1.Rows[i].Cells[0].Text + ",";

                                dr["Subjects"] = gvConsolidatedReport1.Rows[i].Cells[0].Text;
                                dr["PCRC"] = rbPCRC.SelectedValue;
                                pCount += 1;
                                dr["SNo"] = CountRecords++;
                                total += Convert.ToDecimal(PCAMOUNT);
                                receipt.Rows.Add(dr);
                            }
                            else if (rbPCRC.SelectedValue == "RC")
                            {
                                dr = receipt.NewRow();

                                subjects += "RC@" + gvConsolidatedReport1.Rows[i].Cells[1].Text + ",";
                                subjectnames += "RC@" + gvConsolidatedReport1.Rows[i].Cells[0].Text + ",";
                                dr["Subjects"] = gvConsolidatedReport1.Rows[i].Cells[0].Text;
                                dr["PCRC"] = rbPCRC.SelectedValue;
                                rCount += 1;
                                dr["SNo"] = CountRecords++;
                                total += Convert.ToDecimal(RCAMOUNT);
                                receipt.Rows.Add(dr);
                            }
                        }

                        totalAmount = total + Convert.ToDecimal(SERVICECHARGE);
                        Session["TotalAmount"] = totalAmount;
                        Session["PCCOUNT"] = pCount;
                        Session["RCCOUNT"] = rCount;

No comments:

Post a Comment