Solved

add IF condition to html

Posted on 2006-11-10
7
495 Views
Last Modified: 2010-05-18
Hi,


Im using VS2005 with VB.

I have the following line in my page:
<asp:DropDownList SelectedValue='<%#Eval("Status") %>' DataSourceID="odsStatusList" ID="ddlStatus" runat="server" DataTextField="Value" DataValueField="Key" /></td>

which creates a drop down list and binds the selected value.  What I want to do is:

if #Eval("Status") = "Draft" then

    <asp:DropDownList SelectedValue='<%#Eval("Status") %>' DataSourceID="odsStatusList" ID="ddlStatus" runat="server"       DataTextField="Value" DataValueField="Key" /></td>

else

   response.write("Status")

end if

but I dont know how to use the bound item (Status) within code in the page.

Thanks in advance!
0
Comment
Question by:jondow
  • 4
  • 2
7 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 17915818
use TemplateColumn.

See if this will work

<asp:TemplateColumn>
  <ItemTemplate>

<%# if Eval("Status") = "Draft" then%>

    <asp:DropDownList SelectedValue='<%#Eval("Status") %>' DataSourceID="odsStatusList" ID="ddlStatus" runat="server"       DataTextField="Value" DataValueField="Key" /></td>

<%# else%>

   <asp:Label id="lblStatus runat="server" Text="Status" />
<%# end if%>


</ ItemTemplate>
</asp:TemplateColumn>
0
 
LVL 35

Expert Comment

by:YZlat
ID: 17915844
also try

<asp:TemplateColumn>
  <ItemTemplate>

    <asp:DropDownList SelectedValue='<%#Eval("Status") %>' DataSourceID="odsStatusList" ID="ddlStatus" runat="server"       DataTextField="Value" DataValueField="Key" Visible='<%# iif(Eval("Status") = "Draft", True, False)%>' />

   <asp:Label id="lblStatus runat="server" Text="Status" Visible='<%# iif(Eval("Status") <> "Draft", True, False)%>' />
</ ItemTemplate>
</asp:TemplateColumn>
0
 
LVL 2

Author Comment

by:jondow
ID: 17915943
Hi,

its saying templatecolumn is not a known element - i guess because its not part of a gridview?

Anyway I'm off for the weekend now so I'll check back in next week.  Thanks.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 35

Expert Comment

by:YZlat
ID: 17915976
are you using Framework 1.1 or 2.0?
0
 
LVL 35

Accepted Solution

by:
YZlat earned 100 total points
ID: 17915978
then just try

<asp:DropDownList SelectedValue='<%#Eval("Status") %>' DataSourceID="odsStatusList" ID="ddlStatus" runat="server"       DataTextField="Value" DataValueField="Key" Visible='<%# iif(Eval("Status") = "Draft", True, False)%>' />

   <asp:Label id="lblStatus runat="server" Text="Status" Visible='<%# iif(Eval("Status") <> "Draft", True, False)%>' />
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17916816
>>I'm using VS2005 with VB.
The equivalent for TemplateColumn (1.1 DataGrid) with the GridView (2.0) is TemplateField.

Bob
0
 
LVL 2

Author Comment

by:jondow
ID: 17928791
Thanks Guys
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now