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 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
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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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,...
|
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...
|
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.
...
|
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...
|
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...
|
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)...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
| |