?
Solved

add IF condition to html

Posted on 2006-11-10
7
Medium Priority
?
509 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

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!

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

752 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