gridview中的" "问题解决方法
作者:admin 日期:2011-05-04
gridview中的" "问题解决,碰到这个问题是在从excel导入数据过来时碰到的,导了一堆的 比较麻烦;
方法一:
如果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.Cells.Count; j++)
{
if (gdvList.Rows[i].Cells[j].Text == " ")
{
gdvList.Rows[i].Cells[j].Text = "";
}
}
}
http://topic.csdn.net/u/20070812/14/2ad407a7-d265-48b4-b448-5e87aa955b97.html[/i][/i]
方法一:
如果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.Cells.Count; j++)
{
if (gdvList.Rows[i].Cells[j].Text == " ")
{
gdvList.Rows[i].Cells[j].Text = "";
}
}
}
http://topic.csdn.net/u/20070812/14/2ad407a7-d265-48b4-b448-5e87aa955b97.html[/i][/i]