is not generated for null values when using a format string

Discussion in 'ASP .Net Datagrid Control' started by Douglas J. Badin, Dec 2, 2003.

  1. I have a DataGrid with which formats dates

    <ASP:TEMPLATECOLUMN SortExpression="EST_DATE" HeaderText="Est Date">
    <ITEMTEMPLATE>
    <ASP:LABEL runat="server" Text='<%# DataBinder.Eval(Container,
    "DataItem.EST_DATE", "{0:d}") %>'></ASP:LABEL>
    </ITEMTEMPLATE>
    </ASP:TEMPLATECOLUMN>

    If the value is null, a &nbsp is not generated, hence in Netscape the table
    cell is no rendered correctly.

    The only workaround I have found is to use the ?: operator or call a
    procedure to check for "" and replace it with "&nbsp;" like:

    EmptyStringCheck(DataBinder.Eval(Container, "DataItem.EST_DATE", "{0:d}"))


    1. Is there a way to make the DataGrid do this like it does when a
    formatting is not used?

    2. Is there a conditional formatString that if "" then "&nbsp;", like the ?:
    operator?

    3. I tried checking in PreRender, but the TableCell.Text was still "" for
    null and non-null values. So when does Formatting take place in the control
    life cycle?

    WindowsForms has a NullText property but I couldn't find something similar
    for WebForms.

    Thanks,

    Doug
    Douglas J. Badin, Dec 2, 2003
    #1
    1. Advertising

  2. Hi Douglas,

    Thanks for posting in this group.
    Does your application work well on IE client?
    As you state, you can workaround this through "?:" operator which judges
    null and generates &nbsp;.
    I think it should work well. What is the problem of your workaround?

    Best regards,
    Jeffrey Tan
    Microsoft Online Partner Support
    Get Secure! - www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jeffrey Tan[MSFT], Dec 3, 2003
    #2
    1. Advertising

  3. Hi Jeffrey,

    The application does work well on IE. The problem is with Netscape.

    The problem with the workaround is it is a workaround. I am looking for a
    better solution, hopefully something built-in.

    I am still looking for answers to these questions:

    1. Is there a way to make the DataGrid do this like it does when a
    formatting is not used?

    2. Is there a conditional formatString that if "" then "&nbsp;", like the ?:
    operator?

    3. I tried checking in PreRender, but the TableCell.Text was still "" for
    null and non-null values. So when does Formatting take place in the control
    life cycle?

    Thanks,
    Doug


    ""Jeffrey Tan[MSFT]"" <> wrote in message
    news:...
    >
    > Hi Douglas,
    >
    > Thanks for posting in this group.
    > Does your application work well on IE client?
    > As you state, you can workaround this through "?:" operator which judges
    > null and generates &nbsp;.
    > I think it should work well. What is the problem of your workaround?
    >
    > Best regards,
    > Jeffrey Tan
    > Microsoft Online Partner Support
    > Get Secure! - www.microsoft.com/security
    > This posting is provided "as is" with no warranties and confers no rights.
    >
    Douglas J. Badin, Dec 3, 2003
    #3
  4. Hi Douglas,

    Asp.net will judge the client browser's type and generate different html
    code for client.
    To customize the formatString yourself, I think you should do different
    customize on different object type(Because formatstring will take effect on
    different types)
    You can find how to customize formatstring for custom types or Existing
    types from the article below:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
    l/cpconcustomizingformatstrings.asp

    If you want to determine the time asp.net parse formatstring, you can
    override OnPreRender, RenderControl, RenderChildren, Render method to see
    in which method the content changes

    Best regards,
    Jeffrey Tan
    Microsoft Online Partner Support
    Get Secure! - www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jeffrey Tan[MSFT], Dec 4, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Q2FsdmluIEtE?=

    How to display blank instead of &nbsp; in BoundColumn if null

    =?Utf-8?B?Q2FsdmluIEtE?=, Jul 8, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    2,671
    =?Utf-8?B?bG9uZG9uIGNhbGxpbmc=?=
    Jul 8, 2005
  2. Tina

    &nbsp; and null fields

    Tina, Oct 18, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    747
    Mythran
    Oct 19, 2005
  3. Replies:
    5
    Views:
    26,599
    Mike Schilling
    Mar 29, 2006
  4. Tina

    &nbsp; and null fields in a datagrid

    Tina, Oct 18, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    255
    S.M. Altaf [MVP]
    Oct 19, 2005
  5. hotkitty

    Parsing CSV and "&nbsp;&nbsp;"

    hotkitty, Oct 9, 2008, in forum: Perl Misc
    Replies:
    9
    Views:
    335
Loading...

Share This Page