Gridview显示& nbps; [英] Gridview shows &nbps;
本文介绍了Gridview显示& nbps;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我有一个gridview,当我得到列的selecteditem.cells时,如果数据库列为Null或Empty,我指定了对于我的网络表单文本控件,控件显示 而不是string.empty。我怎么能解决这个问题。
解决方案
你可以尝试这个...
让我们说你的gridview在RowDataBound方法中称为gvUsers你可以尝试这个...
protected void gvUsers_RowDataBound( object sender,GridViewRowEventArgs e)
{
< span class =code-keyword> if (e.Row.RowType!= DataControlRowType.DataRow) return ;
DataRow CurrentRow =((DataRow)sender);
for ( int i = 0 ; i < CurrentRow.ItemArray.Count(); i ++)
if ( CurrentRow.ItemArray [i] .ToString()== )
CurrentRow.ItemArray [i] = string .Empty;
}
如果数据库表中的列具有空字符串或空值,则可以指定空字符串或某些默认文本。
hello,
I have a gridview, when I get the selecteditem.cells for a column, if the database column is Null or Empty, and I assign that to my web form text control, the control reads " " instead of a string.empty. How can i solve this .
解决方案
You could try this...
Let say your gridview is called gvUsers in the RowDataBound method you could try this...
protected void gvUsers_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType != DataControlRowType.DataRow) return; DataRow CurrentRow = ((DataRow)sender); for (int i = 0; i < CurrentRow.ItemArray.Count(); i++) if (CurrentRow.ItemArray[i].ToString() == " ") CurrentRow.ItemArray[i] = string.Empty; }
You can assign an empty string or some default text in case your column in the database table is having an empty string or null value.
这篇关于Gridview显示& nbps;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文