Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

add IF condition to html

Posted on 2006-11-10
7
Medium Priority
?
510 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 400 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

618 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