Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GridView - no cell data becomes  

Status
Not open for further replies.

MystiqueOfLife

Programmer
Aug 19, 2006
11
CA
Hello,

This is a question on a GridView.

When storing data in a cell, no data gets set with a value of "nbsp;".

For example, an add form inserts data into a GridView, not all fields in the form contain value, so some GridView columns contain no data, but still for some reason hold a " " value. You notice this when you extract the GridView data to work with it.

To remove the "nbsp;" you do this:
lblData.Text = oGridView.Rows[0].Cells[0].Text.Replace(" ", "");

There must be a better way... I find it odd that you cannot tell the GridView to just store "" inside its cell when no data is passed into that cell.

Any other methods? Thanks appreciate it.
 
[tt] [/tt] represents a blank space in html (non-breaking space i think). different browsers render html differntly. some browsers require this and some don't.

here's a simplified outline of what's happening when you render asp.net

1. get data as business obejct (DataTable, custom object, simple data type)
2. pass business object to an asp.net control (1, "abc", null, "", complex business object)
3. asp.net renders business object to html. if null/"" is encountered, convert to   (not in all cases).
4. display html output.

upon returning to the server to you want to process the user's action. in this case display the value of a gridview cell in a label.
you take the value of step 3 ( ) above and assign it to the control's text value.
instead you should take the value from step 1 (null/empty string)and assign it to the control's text value.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
MystiqueOfLife were you able to solve your issue, since I am encountering the same situation, and have not been able to solve this.

Thanks.
 
This is by design. All empty HTML table cells should have a space ( ) in them to avoid formatting issues.

It's a bad practice to have an empty cell without the space and you should avoid trying to remove it.

MCP, MCTS - .NET Framework 2.0 Web Applications
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top