Answered by:
Nonbreaking space in gridview? How does it get there?

Question
-
User-1767698477 posted
There is no space character in my table. I'm not putting a in my code. It's not in my page for DateSenttoProcessor:
<asp:BoundField DataField="DateSenttoProcessor" HeaderText="Sent to Processor" ReadOnly="True"
SortExpression="DateSenttoProcessor" ItemStyle-HorizontalAlign="Right" />So why when I am debugging and I hover my mouse over e.row.cells(4) there is a &nbdsp; messing up what I'm trying to do. My table value is NULL at the moment
I'm trying to replace the empty cell with the words Not sent and also disable the checkbox on the row. Why does the program generate the ?
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim Senttoprocessor As String = e.Row.Cells(4).Text
Dim Senttoprocesso3r As String = e.Row.Cells(3).Text
If Senttoprocessor = "" Then
e.Row.Cells(4).Text = "Not sent"
e.Row.Cells(1).Enabled = False 'Diable the checkbox
End IfMonday, April 27, 2020 2:21 AM
Answers
-
User409696431 posted
Back in the day, empty table cells with nothing in them would be handled differently by browsers (regarding borders) from table cells with a space in them. As a result GridView puts in empty table cells, so people are not surprised with unexpected border behavior. I don't think that is still an issue with modern browsers, but that is how the GridView works.
You'll need to assume it will happen and adjust your code to handle it
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, April 27, 2020 9:59 AM
All replies
-
User753101303 posted
Hi,
It could be an old trick to properly render empty cells. See what happens if you try:
If Sentroprocessor=" " Then
Not directly related but I try to always render controls based on source data (possibly adding extra properties or computed columns) rather than reading back "data" from the rendered markup.
Monday, April 27, 2020 9:19 AM -
User409696431 posted
Back in the day, empty table cells with nothing in them would be handled differently by browsers (regarding borders) from table cells with a space in them. As a result GridView puts in empty table cells, so people are not surprised with unexpected border behavior. I don't think that is still an issue with modern browsers, but that is how the GridView works.
You'll need to assume it will happen and adjust your code to handle it
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, April 27, 2020 9:59 AM -
User-1767698477 posted
Thanks Kathy. I have adjust my code to handle this issue.
If Senttoprocessor = Nothing Or Senttoprocessor = " " Or Senttoprocessor = "Not sent" Then
Tuesday, April 28, 2020 4:44 AM