I have this code that populates a textbox based on a cell in the selected row of a gridview
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
txtComment.Text = row.Cells[14].Text.Trim();
}
It displays
in the txtComment textbox if Cell[14] has no data.
Is there a way to prevent the
from appearing when there is no data in the cell of the selected row?
Edit I tried this and it didn't work
if (row.Cells[14].Text.Trim().Length > 1)
{
txtComment.Text = row.Cells[14].Text.Trim();
}
else
{
txtComment.Text = row.Cells[14].Text = "";
}
===================================================================
This worked
if (row.Cells[14].Text.Trim()!=" ")
{
txtComment.Text = row.Cells[14].Text.Trim();
}
else
{
txtComment.Text = row.Cells[14].Text = "";
}