您的位置:首页 > 其它

gridview中的" "问题解决方法

2011-07-15 10:25 501 查看
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 = ""; }

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐