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[i].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
方法一:
如果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 = "";
}
}
}
http://topic.csdn.net/u/20070812/14/2ad407a7-d265-48b4-b448-5e87aa955b97.html
[本日志由 admin 于 2011-05-05 01:49 PM 编辑]
上一篇: 《浅薄:互联网如何毒化了我们的大脑》读后感下一篇: 又是一个半年,反思一下
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: gridview
相关日志:
评论: 0 | 引用: 0 | 查看次数: 9115
发表评论