获取通用表的每列的最大值 [英] Get max value of each column of a generic table

查看:90
本文介绍了获取通用表的每列的最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取动态创建的RadGridView的每一列的最大值?

找到后将它们变为红色?



谢谢

How do I get the max value of every columns of a dynamically created RadGridView?
And turn them red when found?

Thanks

推荐答案

请尝试处理RadGrid的PreRender事件,以格式化在数组中添加的列的所有行中最大的单元格,让我知道是否这对你有帮助: -



Please try this out handling the PreRender event of the RadGrid to format the cell which is largest among all rows of the columns added in array and let me know if this helps for you :-

protected void MyRadGrid_PreRender(object sender, EventArgs e)
{
    string[] columns = { "TaxID", "Tax1", "Tax2", "Tax3" };
    foreach (string colName in columns)
    {
        int i = -1;
        decimal max = decimal.MinValue;
        foreach (GridDataItem dtItem in MyRadGrid.MasterTableView.Items)
        {
            decimal currentNo = decimal.Parse(dataItem[colName].Text);
            if (currentNo > maxNumber)
            {
                max = currentNo;
                i = dtItem.ItemIndex;
            }
        }

        if (i >= 0)
        {
            GridTableCell gtCell = (MyRadGrid.Items[i] as GridDataItem)[colName] as GridTableCell;
            gtCell.BackColor = System.Drawing.Color.Red;
        }
    }
}





希望这肯定会有所帮助。



Hope this will definitely be of help.


这篇关于获取通用表的每列的最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆