469,648 Members | 1,549 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,648 developers. It's quick & easy.

datagrid if thens

hi,
I want to display certain data in my edititemtemplate in the datagrid based
on the value of a column. How do I do an if then inside the datagrid AND
test the value of the current column. i only know how to refer to columsn
with the <%# DataBinder.Eval(Container.DataItem, "column") %>, and i can't
include an if then in the <%# %> block. any suggestions?
thanks
-trevor
Nov 17 '05 #1
4 4634
Seems your code would be best in the OnItemCreated event or the
OnItemDataBound event.

If e.Item.Cells(1).Value = 1 Then ...

Here's more info:
http://msdn.microsoft.com/library/de...eatedtopic.asp

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net
"Trevor Hartman" <sy******@hotmail.com> wrote in message
news:uU**************@TK2MSFTNGP10.phx.gbl...
hi,
I want to display certain data in my edititemtemplate in the datagrid based on the value of a column. How do I do an if then inside the datagrid AND
test the value of the current column. i only know how to refer to columsn
with the <%# DataBinder.Eval(Container.DataItem, "column") %>, and i can't
include an if then in the <%# %> block. any suggestions?
thanks
-trevor

Nov 17 '05 #2


Nov 17 '05 #3
Inside as datagrid control you can use the 'IIf([expression], True, False)'
function...

Any function calls in either the 'TruePart or Falsepart' will be called
regardless of the value of [expression]

I use this to toggle the 'visible' attribute in <asp:image /> controls in a
datagrid or datalist like so....

<asp:image id="imgLogo" imageUrl='<%# Container.DataItem("picpath") %>'
visible='<%# IIf(Container.DataItem("picpath") Is DbNull.Value, "False",
"True") %>' />

This IIf() function toggles the image visible to 'False' if "picpath" is
DbNull.Value, else it displays if there is a value in "picpath"

Severin
"Trevor Hartman" <sy******@hotmail.com> wrote in message
news:uU**************@TK2MSFTNGP10.phx.gbl...
hi,
I want to display certain data in my edititemtemplate in the datagrid based on the value of a column. How do I do an if then inside the datagrid AND
test the value of the current column. i only know how to refer to columsn
with the <%# DataBinder.Eval(Container.DataItem, "column") %>, and i can't
include an if then in the <%# %> block. any suggestions?
thanks
-trevor

Nov 17 '05 #4
It is
http://www.microsoft.com/india/msdn/...Questions.aspx

--
Saravana
Microsoft India Community Star,
MCAD,SE,SD,DBA.
"Trevor Hartman" <sy******@hotmail.com> wrote in message
news:#x**************@tk2msftngp13.phx.gbl...

"Saravana" <sa******@sct.co.in> wrote in message
news:O2**************@TK2MSFTNGP09.phx.gbl...
Check out this article,

http://www.microsoft.com/india/msdn/...rQuestions.asp
x

--
Saravana
Microsoft India Community Star,
MCAD,SE,SD,DBA.
"Trevor Hartman" <sy******@hotmail.com> wrote in message
news:uU**************@TK2MSFTNGP10.phx.gbl...
hi,
I want to display certain data in my edititemtemplate in the datagrid

based
on the value of a column. How do I do an if then inside the datagrid AND test the value of the current column. i only know how to refer to columsn with the <%# DataBinder.Eval(Container.DataItem, "column") %>, and i can't include an if then in the <%# %> block. any suggestions?
thanks
-trevor



Nov 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Bill C. | last post: by
2 posts views Thread by pei_world | last post: by
reply views Thread by mgenti | last post: by
2 posts views Thread by Scott | last post: by
2 posts views Thread by CSL | last post: by
7 posts views Thread by Dave | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.