Tech Off Thread

4 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

string.empty and  

Back to Forum: Tech Off
  • User profile image

    Binding dataset to the datagrid... which contains 6 columns and 1 column has string.empty value

    when I see that row.col.value, it contains " " in it. If I hold this value in the string variable, say str1, then str1 = " ". But in the database that field had zero length string, that is string.empty(and database is mssql2k) even, i checked the length of that field using the SQL query, it gives 0 (zero), then why this datagrid is interpreting that string.empty = " ". So finally to solve this I have to replace that " " with "". But still I don't get it... is this a normal way or am I missing something.

  • User profile image

    The DataGrid/GridView actually looks for empty cells and fills them with a   for you.

  • User profile image

    There are many things you have to remember about asp web controls. Two of them are:

    1. When your code runs on the server side, it is seeing the ASP control, not the HTML control that ends up on the page.

    2. ASP controls do not map in a one to one fashion to HTML controls. ASP has to build them out of one or more HTML controls and manipulate their contents to fit the control.

    In this case, #1 means that you are looking at an abstraction that will later be rendered into HTML. #2 means that when a asp:DataGrid is turned into an HTML TABLE, empty cells cannot be left empty or they will not be displayed properly. To deal with this, they are 'filled' with a non-breaking-space.


  • User profile image

      is the non breaking space character in html... or.. a space. Most elements that don't contain a value have the ability to collapse theirself (disapear). Putting a space in ensures they don't.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.