将值覆盖到字符串 [英] coverting a value to a string
本文介绍了将值覆盖到字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨编,
我有一个gridview,当我编辑记录时,它会将我带到另一个视图(标签和文本框),我想要的是状态列,并且它的值为Active的值为"0",InAvtive的值为"1",我需要它当我选择这些值之一显示在网格上(Active,InAvtive)时,知道该coulmn类型为int并试图这样做,则抛出rowdatabound但没有运气.... !! ??
hi progs,
i have a gridview that when i edit records it takes me to another view(labels and textboxes) the thing i want is i have a Status column and it takes values "0" for Active and "1" for InAvtive and i need it that when i choose one of these values display on the grid (Active , InAvtive) knowing that the coulmn type is int and am trying to do that throw rowdatabound but no luck....!!??
推荐答案
您能否将在rowdatabound中使用的代码放入该最佳方法以执行所需的操作,例如:
Could you put the code you used in the rowdatabound cause this best getway to do what ever you want , here an Ex:
protected void OnRowDataBound(object sender, EventArgs e)
{
GridViewRowEventArgs ea = e as GridViewRowEventArgs;
if (ea.Row.RowType == DataControlRowType.DataRow)
{
DataRowView drv = ea.Row.DataItem as DataRowView;
Object ob = drv["Phone"];
if (!Convert.IsDBNull(ob))
{
Int64 iParsedValue = 0;
if (Int64.TryParse(ob.ToString(), out iParsedValue))
{
TableCell cell = ea.Row.Cells[4];
cell.Text = String.Format(System.Globalization.CultureInfo.CurrentCulture,
"{0:(###) ###-####}", new object[] { iParsedValue });
}
}
}
}
您应该在自定义中看到 MSDN页面网格视图 [^ ]
也就是说,您可以简单地做到(在templatefield-> ItemTemplate内)
You should see MSDN''s page on customizing the grid view[^]
That said you could simply do (within the templatefield -> ItemTemplate)
<%# Eval("ColumnContainingInt").ToString() %>
这篇关于将值覆盖到字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文