我注意到,当我填充GridView中选定行的文本框时,如果字段为空,它会在文本框中显示“& nbsp”。空白Gridview单元格填充文本框中的“&nbsp”
这是我提出的解决方案。在将它添加到文本框之前,我会检查每个单元格。
我感觉我要么做错了首要有这个问题,或者有更好的方法来处理这个问题。
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
//// Get the currently selected row using the SelectedRow property.
GridViewRow row = GridView1.SelectedRow;
// Load data from selected row into textboxes
if (row.Cells[1].Text.Trim() != " ")
{
txtEditCust_ID.Text = row.Cells[1].Text.Trim();
}
}
'System.String.Trim()'不会删除'' (文本),至少不在'2.0'中。 – Bobby 2011-11-08 12:40:21
不起作用4.0并非 – 2013-06-06 19:36:04