Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

linq/ help on conditional vb statement

Posted on 2009-05-02
4
Medium Priority
?
414 Views
Last Modified: 2013-11-11
Hi
I have the following statement and would like to make it conditional.

How do I write this into the statement ?

So instead of this:
<td><a href="/courses/<%# Eval("url") %>.aspx" >info</a></td>

Its something like??

If .category = "camps"
    Dim sFormat As string = "<a href="/courses/camps_{0}.aspx" >info</a>"
    Return.String.Format = (sFormat, .url)

Else
   Dim sFormat As string = "<a href="/courses/{0}.aspx" >info</a>"
   Return.String.Format = (sFormat, .url)

EndIf

<td>????</>

Thanks
Tania
Dim xd As New XDocument
          xd = XDocument.Load (Server.MapPath("/App_Data/courseList.xml"))
					
	Dim query = From q In xd...<product> _
		Where Not (q.parent.@code = "ds" or q.parent.@code = "other") _
		Order By q.@title _
		Select New With { _
				.category = q.parent.@title, _
				.summary = q.<shortSummary>.Value, _
				.url = q.<courseUrl>.Value, _
				.title = q.@title, _
				.duration = q.<duration>.Value, _ 
				.dates = (From d In q.<dates>.<date> _
							 Select New With { _
									.date = d.Value}) _	
											 } 			 
						e.Result = query	
						
	End Sub

Open in new window

0
Comment
Question by:Tania_Farmer
  • 2
  • 2
4 Comments
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 2000 total points
ID: 24285966
have you tried this:
If( .category = "camps", string.format("<a href="/courses/camps_{0}.aspx" >info</a>", .url), string.format("<a href="/courses/{0}.aspx" >info</a>", .url))

Open in new window

0
 

Author Comment

by:Tania_Farmer
ID: 24292991
Hi,
How do I format the statement?

<td>

<%# Eval("url"), If( .category = "camps", string.format("<a href="/courses/camps_{0}.aspx" >info</a>", .url), string.format("<a href="/courses/{0}.aspx" >info</a>", .url))%>


</td>

Is it possible to write it above in the Protected Sub listsource_Selecting section?
Protected Sub listsource_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LinqDataSourceSelectEventArgs) Handles listsource.Selecting
		 
     Dim xd As New XDocument
       xd = XDocument.Load (Server.MapPath("/App_Data/courseList.xml"))
                                        
       Dim query = From q In xd...<product> _
          Where Not (q.parent.@code = "ds" or q.parent.@code = "other") _
           Order By q.@title _
           Select New With { _
                                .category = q.parent.@title, _
                                .summary = q.<shortSummary>.Value, _
                                .url = q.<courseUrl>.Value, _
                                .title = q.@title, _
                                .duration = q.<duration>.Value, _ 
                                .dates = (From d In q.<dates>.<date> _
                                                     Select New With { _
                                                                        .date = d.Value}) _     
                                                                                         }                       
                                                e.Result = query        
                                                
        End Sub

Open in new window

0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 2000 total points
ID: 24293912
have you tried replacing:
.url = q.<courseUrl>.Value, _

with:
.url = If( .category = "camps", string.format("<a href="/courses/camps_{0}.aspx" >info</a>", q.<courseUrl>.Value), string.format("<a href="/courses/{0}.aspx" >info</a>", q.<courseUrl>.Value))
0
 

Author Comment

by:Tania_Farmer
ID: 24295419
Hi,
That's exactly what I was looking for.

Thanks
T
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

578 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