Hi,
Do you have any examples on creating a custom footer?
I'm thinking of creating footer that have several labels like the below example
Qty Price Total
1 10.00 10.00
2 20.00 40.00
SubTotal: 50.00
Discount: <textbox here for user input>
Grand Total: <subtotal + discount>
Do you have any examples on creating a custom footer?
I'm thinking of creating footer that have several labels like the below example
Qty Price Total
1 10.00 10.00
2 20.00 40.00
SubTotal: 50.00
Discount: <textbox here for user input>
Grand Total: <subtotal + discount>
3 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 18 Feb 2013, 06:18 AM
Hi,
Please take a look into the following code snippet to give footer for GridBoundColumn.
ASPX:
C#:
Thanks,
Shinu.
Please take a look into the following code snippet to give footer for GridBoundColumn.
ASPX:
<telerik:GridBoundColumn DataField="OrderID"></telerik:GridBoundColumn>C#:
static int total=0; static int discound=0;protected void radQueryResults_ItemDataBound(object sender, GridItemEventArgs e){ if (e.Item is GridDataItem) { GridDataItem dataItem = (GridDataItem)e.Item; int fieldValue = int.Parse(dataItem["OrderID"].Text); total = total + fieldValue; } }protected void radQueryResults_ItemCreated(object sender, GridItemEventArgs e){ if (e.Item is GridFooterItem) { GridFooterItem footerItem = (GridFooterItem)e.Item; Label SubTotal = new Label(); SubTotal.ID = "SubTotal"; SubTotal.Text = "SubTotal"; Label Discount = new Label(); Discount.ID = "Discount"; Discount.Text = "Discount"; Label GrandTotal = new Label(); GrandTotal.ID = "GrandTotal"; GrandTotal.Text = "GrandTotal"; TextBox txtSubTotal = new TextBox(); txtSubTotal.ID = "SubTotalFooter"; TextBox txtDiscountFooter = new TextBox(); txtDiscountFooter.ID = "DiscountFooter"; txtDiscountFooter.AutoPostBack = true; TextBox txtGrandTotalFooter = new TextBox(); txtGrandTotalFooter.ID = "GrandFooter"; footerItem["OrderID"].Controls.Add(SubTotal); footerItem["OrderID"].Controls.Add(txtSubTotal); footerItem["OrderID"].Controls.Add(Discount); footerItem["OrderID"].Controls.Add(txtDiscountFooter); footerItem["OrderID"].Controls.Add(GrandTotal); footerItem["OrderID"].Controls.Add(txtGrandTotalFooter); txtSubTotal.Text = total.ToString(); txtDiscountFooter.TextChanged += new EventHandler(txtDiscountFooter_TextChanged); }}void txtDiscountFooter_TextChanged(object sender, EventArgs e){ TextBox txt = (TextBox)sender; GridFooterItem fitem = (GridFooterItem)txt.NamingContainer; discound = Convert.ToInt32(txt.Text); TextBox GrandTotal = (TextBox)fitem["OrderID"].Controls[5]; GrandTotal.Text = (discound + total).ToString();}Thanks,
Shinu.
0
Accepted
Shinu
Top achievements
Rank 2
answered on 18 Feb 2013, 06:22 AM
Hi,
Please take a look into the following code snippet to give footer for BoundColumn.
ASPX:
C#:
Thanks,
Shinu.
Please take a look into the following code snippet to give footer for BoundColumn.
ASPX:
<telerik:GridBoundColumn DataField="OrderID"></telerik:GridBoundColumn>C#:
static int total=0; static int discound=0;protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e){ if (e.Item is GridDataItem) { GridDataItem dataItem = (GridDataItem)e.Item; int fieldValue = int.Parse(dataItem["OrderID"].Text); total = total + fieldValue; } }
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridFooterItem)
{
GridFooterItem footerItem = (GridFooterItem)e.Item;
TextBox txtSubTotal = new TextBox();
txtSubTotal.ID = "SubTotalFooter";
Label Discount = new Label();
Discount.ID = "Discount";
Discount.Text = "Discount";
TextBox txtDiscountFooter = new TextBox();
txtDiscountFooter.ID = "DiscountFooter";
txtDiscountFooter.AutoPostBack = true;
TextBox txtGrandTotalFooter = new TextBox();
txtGrandTotalFooter.ID = "GrandFooter";
footerItem["OrderID"].Controls.Add(txtSubTotal);
footerItem["OrderID"].Controls.Add(txtDiscountFooter);
footerItem["OrderID"].Controls.Add(txtGrandTotalFooter);
txtSubTotal.Text = total.ToString();
txtDiscountFooter.TextChanged += new EventHandler(txtDiscountFooter_TextChanged);
}
}
void txtDiscountFooter_TextChanged(object sender, EventArgs e)
{
TextBox txt = (TextBox)sender;
GridFooterItem fitem = (GridFooterItem)txt.NamingContainer;
discound = Convert.ToInt32(txt.Text);
TextBox GrandTotal = (TextBox)fitem["OrderID"].Controls[2];
GrandTotal.Text = (discound + total).ToString();
}
Thanks,
Shinu.
0
Shinu
Top achievements
Rank 2
answered on 18 Feb 2013, 06:30 AM
.