Solved

add IF condition to html

Posted on 2006-11-10
7
503 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
Technology Partners: 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 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 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