gridview中的nbsp;问题解决方法
gridview中的" "問(wèn)題解決,碰到這個(gè)問(wèn)題是在從excel導(dǎo)入數(shù)據(jù)過(guò)來(lái)時(shí)碰到的,導(dǎo)了一堆的 比較麻煩;
http://www.dezai.cn/blog/article.asp?id=406
方法一:
如果gridview的boundfield是固定的,只要把每個(gè)datafield的htmlencode屬性設(shè)為"False"
方法二: 使用Replace函數(shù) 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();??? }
}
方法四: 循環(huán)檢查
? //將 替換成空值 ????????
??? 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 = ""; ??????????????????? } ??
????????????? } ?????????
?? }
轉(zhuǎn)載于:https://www.cnblogs.com/eastjazz/archive/2011/07/15/2107094.html
總結(jié)
以上是生活随笔為你收集整理的gridview中的nbsp;问题解决方法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 苹果airpods真假区别
- 下一篇: WordPress中使用mod_rewr