473,396 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how do you add conditional statement to datagrid TemplateColumn

Hi,

Is it possible to add a condition to the value being displayed in a
datagrid template column? Based on the value in the container item I
would like to display one of 2 <asp:Lable> controls.

here is what essentially i'm trying to accomplish

<asp:TemplateColumn HeaderText="ChrgStaDesc" >
<ItemTemplate>
<% if Container.DataItem("detail") <> "" then %>
<asp:Label id= "lblDescription" runat= "server" Text= '<%#
Container.DataItem("detail") %>'></asp:Label>
<% else %>
<asp:Label id= "lblDescription" runat= "server" Text= '<%#
Container.DataItem("detail2") %>'></asp:Label>
<% end if %>
</ItemTemplate>
</asp:TemplateColumn>

thanks in advance!!

Nov 19 '05 #1
1 2518
Handle ItemDataBound event. You have full access to the item and to the
columns and can do whatever you want programmatically.

Eliyahu

"Giorgio" <ro**********@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hi,

Is it possible to add a condition to the value being displayed in a
datagrid template column? Based on the value in the container item I
would like to display one of 2 <asp:Lable> controls.

here is what essentially i'm trying to accomplish

<asp:TemplateColumn HeaderText="ChrgStaDesc" >
<ItemTemplate>
<% if Container.DataItem("detail") <> "" then %>
<asp:Label id= "lblDescription" runat= "server" Text= '<%#
Container.DataItem("detail") %>'></asp:Label>
<% else %>
<asp:Label id= "lblDescription" runat= "server" Text= '<%#
Container.DataItem("detail2") %>'></asp:Label>
<% end if %>
</ItemTemplate>
</asp:TemplateColumn>

thanks in advance!!

Nov 19 '05 #2

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

Similar topics

0
by: shamila | last post by:
</asp:label><asp:datagrid id="DataGrid3" runat="server" cssclass="DataGrid" showfooter="True" onupdatecommand="DataGrid3_Update"ondeletecommand="DataGrid3_Delete" oneditcommand="DataGrid3_Edit"...
3
by: Kevin Pedersen | last post by:
Hello, I am using an editable datagrid. After I save the changes the datagrid shows the old values. I've read the posts about the Page_Load and not binding the datagrid each time. The SQL that...
1
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...
23
by: Wayne Wengert | last post by:
In a Datagrid I have a field (<td>) in which I want to display a link if a database field is still Null but I want to display a blank (&nbsp;) if that DB field has a value. If I try to put the...
2
by: Kumar | last post by:
Hi Folks, I have a question regarding conditional hyperlink in datagrid of asp.net ,c# application I want to display Hyperlink if my QID values in (1,4,5,6) other wise i want to display...
3
by: Lyners | last post by:
I am having a hard time with this one, and I thought it would be easy. I have a datagrid in which I have textboxs for users to enter data. One of the fields in the database behind the datagrid...
0
by: Wyatt70 | last post by:
I'm attempting to implement a javascript popup calendar in a DataGrid. The calendar will be used to insert a date into a textbox. I keep getting a "System.NullReferenceException: Object reference...
1
by: maflatoun | last post by:
Hi, I have a datagrid and based on a condition I like to display either a asp:textbox or asp:label. How would I do that? I have the following <asp:TemplateColumn HeaderText="Qty">...
1
by: maflatoun | last post by:
Hi, I have a datagrid and based on a condition I like to display either a asp:textbox or asp:label. How would I do that? I have the following <asp:TemplateColumn HeaderText="Qty">...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...
0
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...
0
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...

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.