This is a migrated thread and some comments may be shown as answers.

[Solved] display Total for a GridButtonColumn

1 Answer 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sigma
Top achievements
Rank 1
Sigma asked on 22 Mar 2013, 09:10 AM
Hi,

I have a RadGrid with a GridButtonColumn column that display numbers that could be equal zero or any integer bigger than zero.
I want to display in footer how many Zeros i have and how many non zeros i have.
How can i achieve such functionality ?
Thanks

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 22 Mar 2013, 09:26 AM
Hi,

Please try the following code snippet to show the total number of zeros and non zero text in button.

C#:
int zerocount;
int nonzerocount;
protected void RdGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem ditem = (GridDataItem)e.Item;
        Button btn = (Button)ditem["UniqueName"].Controls[0];
        if (btn.Text == "0")
        {
            zerocount++;
        }
        else
        {
            nonzerocount++;
        }
        int fieldValue = Convert.ToInt32(btn.Text);
    }   
    if (e.Item is GridFooterItem)
    {
        GridFooterItem fitem = e.Item as GridFooterItem;
        fitem["ID"].Text = "zerocount=" + zerocount + ",non zero count=" + nonzerocount + "";         
    }
}

Thanks,
Shinu.
Tags
Grid
Asked by
Sigma
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or