我注意到,当我从 gridview 中的选定行填充文本框时,如果该字段为空白,它将在文本框中显示“ ”。
这是我想出的解决方案。在将每个单元格添加到文本框之前,我会检查它。
我觉得我要么一开始就做错了这个问题,要么有更好的方法来处理这个问题。
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();
}
}