Hector Hernandez
Top achievements
Rank 2
Hector Hernandez
asked on 21 Apr 2014, 03:07 AM
Hello.
I have this issue i have grid that i modify data with the event ItemDataBound how can i get the sum and put in the footer of the grid of thes columns, since i dont populate this columns with NeedDataSource
Thanks in advence
I have this issue i have grid that i modify data with the event ItemDataBound how can i get the sum and put in the footer of the grid of thes columns, since i dont populate this columns with NeedDataSource
Thanks in advence
5 Answers, 1 is accepted
0
Jayesh Goyani
Top achievements
Rank 2
answered on 21 Apr 2014, 05:07 AM
Hello,
Please try with the below code snippet.
Let me know if any concern.
Thanks,
Jayesh Goyani
Please try with the below code snippet.
foreach
(GridFooterItem footeritem
in
RadGrid1.MasterTableView.GetItems(GridItemType.Footer))
{
//Access TemplateColumn's Control
TextBox textbox = (TextBox)footeritem.FindControl(
"YourTextBoxID"
);
//Access bound column
footeritem[
"YOurColumnUNiqueName"
].Text =
"Your Value"
;
}
//OR
GridFooterItem footeritem = (GridFooterItem)RadGrid1.MasterTableView.GetItems(GridItemType.Footer)[0];
if
(GridFooterItem !=
null
)
{
//Access TemplateColumn's Control
TextBox textbox = (TextBox)footeritem.FindControl(
"YourTextBoxID"
);
//Access bound column
footeritem[
"YOurColumnUNiqueName"
].Text =
"Your Value"
;
}
Let me know if any concern.
Thanks,
Jayesh Goyani
0
Jayesh Goyani
Top achievements
Rank 2
answered on 21 Apr 2014, 05:08 AM
Hello,
You can write above code snippet in either in page_Prerender event or in Radgrid_Prerender event.
Thanks,
Jayesh Goyani
You can write above code snippet in either in page_Prerender event or in Radgrid_Prerender event.
Thanks,
Jayesh Goyani
0
Accepted
Shinu
Top achievements
Rank 2
answered on 21 Apr 2014, 05:23 AM
Hi Hector Hernandez,
You can set the sum of a column at footer text in the ItemDataBound event as follows:
ASPX:
C#:
Thanks,
Shinu
You can set the sum of a column at footer text in the ItemDataBound event as follows:
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
OnItemDataBound
=
"RadGrid1_ItemDataBound"
ShowFooter
=
"true"
>
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
int
total = 0;
if
(e.Item
is
GridDataItem)
{
GridDataItem dataItem = (GridDataItem)e.Item;
int
fieldValue =
int
.Parse(dataItem[
"ColumnUniqueName"
].Text);
total = total + fieldValue;
}
if
(e.Item
is
GridFooterItem)
{
GridFooterItem footerItem = (GridFooterItem)e.Item;
footerItem[
"ColumnUniqueName"
].Text =
"Total: "
+ total.ToString();
}
}
Thanks,
Shinu
0
Hector Hernandez
Top achievements
Rank 2
answered on 22 Apr 2014, 05:55 PM
Thank you Jayesh
Work great.
Work great.
0
Hector Hernandez
Top achievements
Rank 2
answered on 22 Apr 2014, 05:59 PM
Thank you Shinu!!
Wonderfull!!
Wonderfull!!