473,385 Members | 1,602 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,385 software developers and data experts.

datagrid itemtemplate help

Dear All,

In my datagrid, i want to add a logic to it. that is, if the result for the
data equals to "Yes",
a "asp:label" control will be displayed; otherwise a "asp:imagebutton"
control will be shown

<ItemTemplate>
<% if DataBinder.Eval(Container.DataItem, "boflag").equals("Yes") then%>
<asp:Label id="Label1" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem,"boflag")%>'></asp:Label>
<% Else %>
<asp:imagebutton id="imgBtnUpdate" runat="server" NAME="Imagebutton3"
ImageUrl="no.gif"></asp:imagebutton>
<% end if %>
</ItemTemplate>

However, "<% if DataBinder.Eval(Container.DataItem,
"boflag").equals("Yes") then%> " this is not valid.

So, how can i get the data to compare the value.

Thank you.

Regards,
Angus
Nov 18 '05 #1
2 5222
Angus,

ASP.NET page is not a program. It can't run statements. You can databind
Visible property of your Label and ImageButton to the expression you have in
the if-part.

Eliyahu

"angus" <an***@angus.com> wrote in message
news:ue*************@TK2MSFTNGP10.phx.gbl...
Dear All,

In my datagrid, i want to add a logic to it. that is, if the result for the data equals to "Yes",
a "asp:label" control will be displayed; otherwise a "asp:imagebutton"
control will be shown

<ItemTemplate>
<% if DataBinder.Eval(Container.DataItem, "boflag").equals("Yes") then%> <asp:Label id="Label1" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem,"boflag")%>'></asp:Label>
<% Else %>
<asp:imagebutton id="imgBtnUpdate" runat="server" NAME="Imagebutton3" ImageUrl="no.gif"></asp:imagebutton>
<% end if %>
</ItemTemplate>

However, "<% if DataBinder.Eval(Container.DataItem,
"boflag").equals("Yes") then%> " this is not valid.

So, how can i get the data to compare the value.

Thank you.

Regards,
Angus

Nov 18 '05 #2
Hello Angus,

You can do something like that. Hope that it can help

Dim lblTemp As Label

For i As Integer = 0 To mydatagrid.Items.Count - 1

lblTemp = mydatagrid.Items(i).Cells(n).FindControl("Label1")

If Not lblTemp.Text.Equals("Yes") Then

mydatagrid.Items(i).Cells(n).Controls.add(<img button control here>)

End If

Next

"angus" <an***@angus.com> wrote in message
news:ue*************@TK2MSFTNGP10.phx.gbl...
Dear All,

In my datagrid, i want to add a logic to it. that is, if the result for the data equals to "Yes",
a "asp:label" control will be displayed; otherwise a "asp:imagebutton"
control will be shown

<ItemTemplate>
<% if DataBinder.Eval(Container.DataItem, "boflag").equals("Yes") then%> <asp:Label id="Label1" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem,"boflag")%>'></asp:Label>
<% Else %>
<asp:imagebutton id="imgBtnUpdate" runat="server" NAME="Imagebutton3" ImageUrl="no.gif"></asp:imagebutton>
<% end if %>
</ItemTemplate>

However, "<% if DataBinder.Eval(Container.DataItem,
"boflag").equals("Yes") then%> " this is not valid.

So, how can i get the data to compare the value.

Thank you.

Regards,
Angus

Nov 18 '05 #3

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

Similar topics

6
by: Derek | last post by:
I have an aspx page where I use a reversebind and templates to edit the entire datagrid at one time. I added a textbox and button to change the parameter criteria and then rerun the databind2...
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...
7
by: localhost | last post by:
A DataGrid with shows a label in one of the columns when in view mode. When in edit mode, I want to show a dropdown, and have the default selection set to what the textbox used to be. Right now...
0
by: Hai Nguyen | last post by:
Below is my code, would anybody please figure out why it did not display any thing. The database did not anything in there yet, what it does is the header field. It just shows me the headers only,...
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...
3
by: tjonsek | last post by:
am working on code that will allow users to update data within the datagrid. I have come across a few problems, some of them I have been able to work out, but this last one is giving me trouble. ...
6
by: p.mc | last post by:
Hi all, I'm having major problems with a userControl which contains a datagrid. My problem concerns data binding. The Page_Load() procedure calls the DataBind procedure to bind the datagrid...
2
by: Charleees | last post by:
Hi all, I have a DataGrid with Template Columns..... There are LAbels,Linkbuttons in the Single Row.. I have to set the Constant Column width for those Template Columns in Grid... Wat...
0
by: Rocky | last post by:
Dear ALL, I am facing a bit problem in DATAGRID. so may be you guys can help me out. Actually on a DataGrid I am having following controls: 1) 2 DropDown Menu 2) 1 Text Box 3) 1 ADD Button 4)...
1
by: Steven Van Eyck | last post by:
Hi there There are probably lots of questions being posted about datagrids, but I can't resist... ;-) Here's my issue: I have an aspx page with a datagrid in which I manually declare the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.