Hello. I am coming from using the Obout.com grid control which I used to calculate some values. Is it possible to do the same thing using the ASP.net Grid by Syncfusion? If so, is there any sample or help to direct me? Thank you very much!
public void RowDataBound(object sender, GridRowEventArgs e)
{
try
{
//Individual Rows
if (e.Row.RowType == GridRowType.DataRow)
{
//This will remove sales tax for a reseller.
if (((GridDataControlFieldCell)e.Row.Cells[8]).Text == "True")
{
salesTaxRate = 0;
}
else
{
salesTaxRate = Convert.ToDecimal(s.SalesTaxRate);;
}
//Column: WinningPrice / Price itemWinningPrice
decimal itemPrice = decimal.Parse(e.Row.Cells[9].Text);
//Calculate amounts
decimal itemTax = salesTaxRate * itemPrice;
decimal itemBuyerPremium = buyerPremiumRate * itemPrice;
decimal itemTotal = itemPrice + itemTax + itemBuyerPremium;
decimal itemCashPrice = (buyerPremiumRate - cashDiscount) * itemPrice + itemTax + itemPrice;
//////
//Display Values
//Tax
e.Row.Cells[10].Text = itemTax.ToString("C");
//Buyer Premium
e.Row.Cells[11].Text = itemBuyerPremium.ToString("C");
//Item Total
e.Row.Cells[12].Text = itemTotal.ToString("C");
//Cash Price
e.Row.Cells[13].Text = itemCashPrice.ToString("C");
//Add item price to total
totalItemPriceForUser += itemPrice;
}
else if (e.Row.RowType == GridRowType.GroupFooter)
{
//Show Total for User:
decimal totalTaxForUser = 0;
decimal totalBuyerPremiumForUser = 0;
decimal totalLineTotalForUser = 0;
decimal totalCashPriceForUser = 0;
//Tax
totalTaxForUser = totalItemPriceForUser * salesTaxRate;
//Rounding
totalTaxForUser = Math.Round(totalTaxForUser, 2, MidpointRounding.AwayFromZero);
//Buyer Premium
totalBuyerPremiumForUser = totalItemPriceForUser * buyerPremiumRate;
//Rounding
totalBuyerPremiumForUser = Math.Round(totalBuyerPremiumForUser, 2, MidpointRounding.AwayFromZero);
//Total
totalLineTotalForUser = totalItemPriceForUser + totalTaxForUser + totalBuyerPremiumForUser;
//Rounding
totalLineTotalForUser = Math.Round(totalLineTotalForUser, 2, MidpointRounding.AwayFromZero);
//Cash Price
totalCashPriceForUser = totalItemPriceForUser + totalTaxForUser + totalItemPriceForUser * (buyerPremiumRate - cashDiscount);
//Rounding
totalCashPriceForUser = Math.Round(totalCashPriceForUser, 2, MidpointRounding.AwayFromZero);
//Display Totals
e.Row.Cells[2].Text = "<strong><span style =\"text-decoration: underline;\"> Total for User:</span></strong>";
//Total Item Price
e.Row.Cells[9].Text = "<strong>" + totalItemPriceForUser.ToString("C") + "</strong>";
e.Row.Cells[10].Text = "<strong>" + totalTaxForUser.ToString("C") + "</strong>";
e.Row.Cells[11].Text = "<strong>" + totalBuyerPremiumForUser.ToString("C") + "</strong>";
e.Row.Cells[12].Text = "<strong>" + totalLineTotalForUser.ToString("C") + "</strong>";
e.Row.Cells[13].Text = "<strong>" + totalCashPriceForUser.ToString("C") + "</strong>";
//Add to grand totals
//Item Price
grandTotalItemPrice += totalItemPriceForUser;
//Tax
grandTax += totalTaxForUser;
//Buyer Premium
grandBuyerPremium += totalBuyerPremiumForUser;
//Line Total
grandLineTotal += totalLineTotalForUser;
//Cash Price
grandcashPrice += totalCashPriceForUser;
//Reset the values to 0
totalItemPriceForUser = 0;
totalTaxForUser = 0;
totalBuyerPremiumForUser = 0;
totalCashPriceForUser = 0;
totalLineTotalForUser = 0;
}
else if (e.Row.RowType == GridRowType.ColumnFooter)
{
//Display Grand Totals
e.Row.Cells[2].Text = "<strong>Grand Total for All:</strong>";
e.Row.Cells[9].Text = "<strong>" + grandTotalItemPrice.ToString("C") + "</strong>";
e.Row.Cells[10].Text = "<strong>" + grandTax.ToString("C") + "</strong>";
e.Row.Cells[11].Text = "<strong>" + grandBuyerPremium.ToString("C") + "</strong>";
e.Row.Cells[13].Text = "<strong>" + grandcashPrice.ToString("C") + "</strong>";
e.Row.Cells[12].Text = "<strong>" + grandLineTotal.ToString("C") + "</strong>";
}
if (e.Row.RowType == GridRowType.DataRow)
{
//Group Header
if (lastGroupHeader != null)
{
Literal textContainer = lastGroupHeader.Cells[0].Controls[0].Controls[lastGroupHeader.Cells[0].Controls[0].Controls.Count - 1].Controls[0] as Literal;
textContainer.Text = "<u>Username: <strong>" + ((GridDataControlFieldCell)e.Row.Cells[7]).Text;
textContainer.Text += "</strong> Full Name: " + ((GridDataControlFieldCell)e.Row.Cells[3]).Text;
textContainer.Text += " " + ((GridDataControlFieldCell)e.Row.Cells[4]).Text;
textContainer.Text += " Phone Number: " + ((GridDataControlFieldCell)e.Row.Cells[5]).Text;
textContainer.Text += " City: " + ((GridDataControlFieldCell)e.Row.Cells[6]).Text;
textContainer.Text += " State: " + ((GridDataControlFieldCell)e.Row.Cells[14]).Text + "</u>";
lastGroupHeader = null;
}
}
else if (e.Row.RowType == GridRowType.GroupHeader)
{
//Sets something :)
if (e.Row.GroupLevel == 0)
{
lastGroupHeader = e.Row;
}
}
}
catch
{
}
}