Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 1.54 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. gridview selected value
  2. Sector Name    Amount Invested
  3. Finance        300000
  4. Properties     100000
  5. ...            ...
  6.        
  7. double TotalInvestments = 0.0;
  8.  
  9. for (int i = 0; i < gvSector.Rows.Count; i++)
  10. {
  11.     if (gvSector.Rows.Count > 0)
  12.     {  
  13.         double SAmt = Convert.ToDouble(gvSector.Rows[i].Cells[1].Text);
  14.         TotalInvestments += SAmt;
  15.         double PercentSAmt = (SAmt / TotalInvestments) * 100;
  16.  
  17.         if (PercentSAmt > 25.0)
  18.         {
  19.             //I've no idea what to put here. It is supposed to show the sector(s) that is more than 25% from the gridview.
  20.  
  21.         }    
  22.     }
  23. }
  24.        
  25. protected void Grid_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
  26. {
  27.     if (e.Row.RowType == DataControlRowType.DataRow) {
  28.         var data = (DataRowView)e.Row.DataItem;
  29.         var lbSector = (Label)e.Row.FindControl("lbSector");
  30.         var amount = (int)data("Amount");
  31.         var amountOverAll = (long)data.DataView.Table.Compute("SUM(Amount)", null);
  32.         if (amount * 100 / amountOverAll >= 30) {
  33.             lbSector.Text = data("Sector").ToString();
  34.         }
  35.     }
  36. }
  37.        
  38. double SAmt = Convert.ToDouble(gvSector.Rows[i].Cells[1].Text);
  39.         TotalInvestments += SAmt;
  40.         double PercentSAmt = (SAmt / TotalInvestments) * 100;
  41.        
  42. double PercentSAmt = (SAmt / TotalInvestments) * 100;
  43.  if (PercentSAmt > 30.0)
  44.  {          
  45.     gvSector.Rows[i].Cells[1].Text
  46.  }
  47.        
  48. double PercentSAmt = (SAmt / TotalInvestments) * 100;
  49.  if (PercentSAmt > 30.0)
  50.  {          
  51.     lbSector.Text +=  gvSector.Rows[i].Cells[0].Text + " ";
  52.  }