C# 在ASPxGridView中设置单个值
我有一个从数据库填充的ASPxGridView。我的代码中的所有内容都正常工作(大约95%确定这一点),我基本上想调用C# 在ASPxGridView中设置单个值,c#,asp.net,webforms,devexpress,C#,Asp.net,Webforms,Devexpress,我有一个从数据库填充的ASPxGridView。我的代码中的所有内容都正常工作(大约95%确定这一点),我基本上想调用 e.SetValue("MeanTime") = meanTimeCell; 不幸的是,这并不存在。我已经找过了,但找不到答案 protected void RTMonitoringGrid_HtmlRowCreated(object sender, DevExpress.Web.ASPxGridViewTableRowEventArgs e) if (e.RowT
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之前尝试格式化数据,但我认为这同样困难。制作一个未绑定的列,并在customUnboundColumnData事件中处理gridviews。在这种情况下,将该值设置为您想要的值 编辑:实际上,因为您只需要从数据库中取整数字(如果您愿意将s放在它的末尾),只需将列的DisplayFormat.FormatType设置为“Numeric”,DisplayFormat.FormatString显示您想要的小数位数
您也可以遵循devexpress线程中列出的方法您必须在某个时候更新数据库。你有没有编写一个方法来完成更新?我在项目中没有使用过很多代码。我已经为我导入了数据库,但是如果需要的话,我可能会找到一个更新语句。好的,很好。您需要更改
GridView
的一些事件,例如OnRowEditing
和onrowUpdate
,以处理更新过程。这包括有关如何设置GridView
的步骤。DevExpress的GridView与普通asp GridView有不同的方法。上面的例子并不能解决我的问题。你不需要更新任何东西来显示数字的四舍五入版本