473,511 Members | 16,110 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid control

I'm using a DataGrid to display data returned from a database.
I've got a template column which displays the results from several fields.
Within this template column I want to display certain fields but only if the
data in a particular field is not null, but I can't get it to work:

<itemtemplate>
....
<%# If Not IsDBNull(DataBinder.Eval(Container.DataItem, "EditedBy") Then
DataBinder.Eval(Container.DataItem, "EditedBy") & " " &
DataBinder.Eval(Container.DataItem, "DateEdited")
End If %>
</itemtemplate>

How should I do this?

Many thanks for any help.

Alan
Nov 18 '05 #1
1 938
Here is one option:

<ItemTemplate>
<%# IIf (IsDBNull(DataBinder.Eval(Container.DataItem, "EditedBy"), ' ',
DataBinder.Eval(Container.DataItem, "EditedBy") & " " &
DataBinder.Eval(Container.DataItem, "DateEdited")) %>
</ItemTemplate>

"Alan Lambert" <Al*********@discussions.microsoft.com> wrote in message
news:0D**********************************@microsof t.com...
I'm using a DataGrid to display data returned from a database.
I've got a template column which displays the results from several fields.
Within this template column I want to display certain fields but only if the
data in a particular field is not null, but I can't get it to work:

<itemtemplate>
....
<%# If Not IsDBNull(DataBinder.Eval(Container.DataItem, "EditedBy") Then
DataBinder.Eval(Container.DataItem, "EditedBy") & " " &
DataBinder.Eval(Container.DataItem, "DateEdited")
End If %>
</itemtemplate>

How should I do this?

Many thanks for any help.

Alan
Nov 18 '05 #2

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

Similar topics

5
2568
by: Jeff | last post by:
IDE: VS 2003 :NET OS: XP Pro My app have a form with a tab-control on it. The tab-control have 2 tabpages. One of the tabpages displays a datagrid, and the other tabpage displays details (order...
2
2656
by: Carolyn Vo | last post by:
I have been looking and looking but can't seem to find out how to get the row selected in a web control datagrid (NOT a web form datagrid!!!), and how to highlight the selected row. I'm sure this...
4
5335
by: Glenn Owens | last post by:
I have a DataGrid web control which I've dynamically populated with template columns to be used for bulk-editting. Generally, all of the columns are textbox and/or dropdownlist child controls. ...
1
2111
by: thegame | last post by:
Filling One DataGrid Based on Selection from Another DataGrid - Both in Separate User Controls Hello, I have an interesting dilemma. I have an ASPX page with two user controls (two ASCXs). ...
13
2452
by: pmcguire | last post by:
I have a DataGrid control for which I have also created several new extended DataGridColumnStyles. They behave pretty nicely, but I can't figure out how to implement Selected Item formatting for...
0
7138
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...
0
7353
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7075
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7508
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...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3222
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...
0
3212
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
446
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.