我有此代碼用於填充基於小區一個gridview防止空的GridView數據
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
txtComment.Text = row.Cells[14].Text.Trim();
}
它顯示
在txtComment文本框的選定行中的文本框如果細胞[ 14]沒有數據。
當選定行的單元中沒有數據時,是否有辦法阻止
出現?
編輯 我嘗試這樣做,也沒有工作
if (row.Cells[14].Text.Trim().Length > 1)
{
txtComment.Text = row.Cells[14].Text.Trim();
}
else
{
txtComment.Text = row.Cells[14].Text = "";
}
========================= ==================================================================================
這工作
if (row.Cells[14].Text.Trim()!=" ")
{
txtComment.Text = row.Cells[14].Text.Trim();
}
else
{
txtComment.Text = row.Cells[14].Text = "";
}
你有沒有試過'row.Cells [14] .Text = string.Empty;'或'=「」;'? – 2010-09-17 18:18:45
我試了兩個=字符串。空的;和=「」;並且我仍然收到了 – 2010-09-17 18:30:14