gridview中的" "问题解决,碰到这个问题是在从excel导入数据过来时碰到的,导了一堆的 比较麻烦;
http://www.dezai.cn/blog/article.asp?id=406
方法一:
如果gridview的boundfield是固定的,只要把每个datafield的htmlencode属性设为"False"
方法二: 使用Replace函数 Strings.Replace(TableCell.Text, " ", "")
方法三:
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(); }
}
方法四: 循环检查
//将 替换成空值
for (int i = 0; i < gdvList.Rows.Count; i++)
{
for (int j = 0; j < gdvList.Rows[i].Cells.Count; j++)
{
if (gdvList.Rows[i].Cells[j].Text == " ")
{
gdvList.Rows[i].Cells[j].Text = ""; }
}
}