繁体   English   中英

在ASPxGridView中设置单个值

[英]Setting individual values in ASPxGridView

我有一个从数据库填充的ASPxGridView。 我代码中的所有内容均正常运行(对此大约有95%的把握),我实质上想调用

e.SetValue("MeanTime") = meanTimeCell;

不幸的是,这并不存在。 我已经搜索过了,但是找不到答案。

protected void RTMonitoringGrid_HtmlRowCreated(object sender, DevExpress.Web.ASPxGridViewTableRowEventArgs e)
     if (e.RowType == DevExpress.Web.GridViewRowType.Data) 
     {
        //this gets a value in the GridView 
        string meanTimeCell = e.GetValue("MeanTime").ToString();

        try
        {
           double result;
           if (double.TryParse(meanTimeCell, out result))
           {  
              //this is the string I essentially want to overwrite the old cell data with
              meanTimeCell = string.Format("{0}s", Math.Round(result, 1));
              //SetValue would be called here
           }
        }
        catch (Exception ex)
        {

        }
     }
}

有人知道一个简单的解决办法吗? 我曾考虑过尝试在将数据放入ASPxGridView之前对数据进行格式化,但事实证明,这同样困难。

制作一个未绑定的列并处理gridviews onCustomUnboundColumnData事件。 在这种情况下,请将值设置为所需的值。

编辑:实际上,因为您只需要舍入数据库中的数字(如果您愿意将s放在它的末尾),只需将列的DisplayFormat.FormatType设置为“ Numeric”和DisplayFormat.FormatString即可显示许多小数位你要。

您还可以按照此处列出的devexpress线程中的方法进行操作

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM