簡體   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