Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control >   is not generated for null values when using a format string

Reply
Thread Tools

  is not generated for null values when using a format string

 
 
Douglas J. Badin
Guest
Posts: n/a
 
      12-02-2003
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


 
Reply With Quote
 
 
 
 
Jeffrey Tan[MSFT]
Guest
Posts: n/a
 
      12-03-2003

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.

 
Reply With Quote
 
 
 
 
Douglas J. Badin
Guest
Posts: n/a
 
      12-03-2003
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]"" <v-> 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.
>



 
Reply With Quote
 
Jeffrey Tan[MSFT]
Guest
Posts: n/a
 
      12-04-2003

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/de...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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: raw format string in string format method? Chris Angelico Python 3 03-01-2013 12:00 AM
Re: raw format string in string format method? Rick Johnson Python 0 02-28-2013 11:06 PM
Re: raw format string in string format method? Peter Otten Python 0 02-28-2013 03:41 PM
Simple error : method format(String, Object[]) is not applicable for the arguments (String, String) ankur Java 1 08-27-2007 06:31 AM
"stringObj == null" vs "stringObj.equals(null)", for null check?? qazmlp1209@rediffmail.com Java 5 03-29-2006 10:37 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57