Tag: gridview预览模式: 普通 | 列表

gridview中的" "问题解决方法

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]

查看更多...

Tags: gridview

分类:编程技术 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 8768