我需要知道如何使用类来获取字符串并将其添加到 agridview 中的 itemtemplate 内的标签中...
我之前发布过这个问题: Add text from c# code to a gridview label
我得到了一个答案,我注意到我从一个cs文件中的一个类中获取了字符串......更具体地说,这是我的类:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace ClientesPagos
{
public class Funciones
{
public static string GetFormatoMoneda(decimal decCantidad)
{
DataRow dr = ConexionBD.GetInstanciaConexionBD().GetTipoDeMonedaPrincipal((int)HttpContext.Current.Session["Grupo"]);
return dr["Signo"] + Math.Round(decCantidad, 2).ToString("C").Substring(1) + " " + dr["Abreviatura"];
}
}
}
从其中一个建议中,我尝试使用它:
Text='<%#Funciones.GetFormatoMoneda(Eval("Total"))%>'
不工作...
然后我尝试了一些我不想做的事情,但只是为了测试我尝试了它。我的 gridview 在一个名为 Ventas.aspx 的文件中......所以我在 Ventas.aspx.cs 上添加了相同的类,然后我将文本切换为:
Text='<%#GetFormatoMoneda(Eval("Total"))%>'
另外,我尝试将 GetFormatoMoneda(decimal decCantidad) 切换到 GetFormatoMoneda(object objCantidad),但完全没有成功...
你知道解决这个问题的方法吗?或者您是否可以对上面链接中的另一个问题提供不同的答案?