473,803 Members | 3,913 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid, empty date: How show nothing for date value - now shows 1/1/0001??

Hi

I have a column in my datagrid that can have values of null at times. I am not assigning any value to it, if it is coming from Database empty. Now, the problem is I guess the datetime variables have a default value. Thus shows an undesirable value of 1/1/0001

How do I go about not showing anything when the value is null like this

Thanks in advance
Reza
Nov 18 '05 #1
1 3000
are you sure they are nulls or just empty data fields. (In my experience
"nulls" crash things if you haven't specifically coded around them) Either
way, you should be able to define a function that you can put in your
databinding syntax <%# %> or in your itemdatabound event that will give you
the date you want. Your function would be something like this.

Private Function getDate(ByVal myDate As Object) As String
getDate = CStr(myDate)

If getDate = "1/1/0001" Then
getDate = String.Empty
End If

Return getDate
End Function

then in your datagrid, define a templatecolumn for this column
<asp:templateco lumn headertext="Dat e">
<itemtemplate >
<%# getDate(DataBin der.Eval(Contai ner.DataItem, "myDate")) %>
</itemtemplate>
</asp:templatecol umn>

hope this helps
--Michael

"Reza" <uw******@hotma il.com> wrote in message
news:F6******** *************** ***********@mic rosoft.com...
Hi,

I have a column in my datagrid that can have values of null at times. I am not assigning any value to it, if it is coming from Database empty. Now, the
problem is I guess the datetime variables have a default value. Thus shows
an undesirable value of 1/1/0001.
How do I go about not showing anything when the value is null like this?

Thanks in advance,
Reza

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2768
by: SammyBar | last post by:
Hi, I'm trying to bind a custom collection class to a data grid, following the guidelines from the article http://msdn.microsoft.com/msdnmag/issues/05/08/CollectionsandDataBinding/default.aspx. The problem is the article is in VisualBasic. I already get the collection to be recognized as a Data Source by the IDE. It populated the DataGrid correctly from the fields on the items object of the collection, but I can't get the DataGrid to...
1
2446
by: Jac | last post by:
Hi, In my datagrid I have following line : <asp:BoundColumn DataField="VervalDt" HeaderText="Vervaldatum" DataFormatString="{0:d}"></asp:BoundColumn> But I want an empty column when my datafield (VervalDt) = 01/01/0001 (= DateTime.MinValue) So, if my date = 01/01/0001 I want to put an empty string in that column,
0
3552
by: Mauro | last post by:
Hi, I need a big help to resolve this problem. I need to put a usercontrol in a datagrid: this control check if the code inserted is present in a archive and if not return a error message. (In the example I have changed this check with a easy "if string is empty" ) Everything would be easy if the datagrid had a predictable behaviour. I explain my problem.
3
4889
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that the best method? Do you have a sample of how to do this?
1
4345
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls (watch the layout, some have child controls):
3
1956
by: Paul Say | last post by:
I have a class called Job, that has several properties JobID,Description & StartDate. The StartDate is Property is defined as follows public Class Job private _StartDate as DateTime public property StartDate() as DateTime get return _StartDate
5
5233
by: Tan | last post by:
I am using ObjectDataSource bind to DetailView which will contain one of the column with the value type is date. whenver the value of this column is empty . then it will be display the date in the format ( 01/01/0001), How can I convert it to empty string or just string? Thank you very much tan
2
2129
by: pmcguire | last post by:
I have derived a ComboBoxColumnStyle that inherits DataGridColumnStyle. It works fine except for one behavior. If the user selects a new value from the ComboBox's pulldown list on a brand new record, the ComboBoxColumn's Commit event doesn't fire. If the user first edits a TextBox cell on the same New row, and THEN selects a new value for the ComboBox cell, Commit fires. What is going on and how do I get around it Thanks Pat
1
2370
by: jimb | last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .. http://sf-f.org, weblog and search engine for fans and writers of
0
9703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9564
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9125
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7604
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5500
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.