Another alternative:
string gridValue = DataBinder.Eval(dataItem, dataField, "{0}");
Also, don't
Eval
the same value multiple times; use the value retrieved from the first call to
Eval
instead:
protected string gridValueChopping(object dataItem, string dataField, int iSize)
{
string gridValue = DataBinder.Eval(dataItem, dataField, "{0}");
string output;
if (gridValue.Length > iSize)
{
output = gridValue.Substring(0, iSize - 3);
output = output + "...";
}
else
{
output = gridValue;
}
return output;
}