how to replace blank text in gridview cell with -- ??

Posted by Laghaterohan under Regular Expressions on 12/20/2010 | Points: 10 | Views : 4999 | Status : [Member] | Replies : 1
Hello Friends,

I have a gridview with 4 columns , and my 5th column is a template field inside which i have placed a label and 6th is a Select button.

I bind data to my gridview and after that i replace blank spaces with " -- " for proper look.

However, what i get to see is that my template field column although it contains data gets replaced with " -- ". Does any one know why does this happen??
I write following code :

foreach (GridViewRow row in GridView1.Rows)
{
for (int i = 0; i < row.Cells.Count - 1; i++)
{
if (row.Cells[i].Text == string.Empty || row.Cells[i].Text == "&nbsp;")
{
row.Cells[i].Text = "--";
}
}
}



Thanks!!!
Happy Coding :)

Best Regards,
Rohan Laghate



Responses

Posted by: Vuyiswamb on: 12/21/2010 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down

"&nbsp;" Does not mean blank, use an empty string

Thank you for posting at Dotnetfunda
[Administrator]

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response