Conditional Values in DataList

W

Wayne Wengert

I am trying to build a project in VSNET 2003 using a sql datareader and
a datalist. I want to have one column display either a hyperlink or a
simple test string based on the values in one of the data fields. I have
tried many combinations of code but cannot get it to work. My current
code is listed below. From searching google I believe thast the
DataRowView type works only with a datagrid. Any suggestions are
appreciated

============= code snippets ============
Public Function SetValue(ByVal data As DataRowView) As String
Dim strResult As String
If data("ProposedStatus") Is DBNull.Value Then
strResult = String.Format( _

"http://wengert.org/evaljudge.asp?name={0}&caption={1}&evalid={2}", _
data("JudgeName"), data("Caption"), data("EvalID"))
Else
strResult = ""
End If
Return strResult
End Function

.......

<asp:DataList id="judgelist" runat="server">
<HeaderTemplate>
<table width="90%">
<tr bgcolor="#b0c4de">
<th>
Action</th>
<th>
Judge</th>
<th>
Caption</th>
<th align="center">
Current<br />
Status</th>
<th align="center">
Proposed<br />
Status</th>
<tr>
</HeaderTemplate>
<ItemTemplate>
<tr bgcolor="lightcyan">
<td id="myLink" runat="server">
SetValue()
</td>
 
B

Bob Barrows [MVP]

Wayne said:
I am trying to build a project in VSNET 2003 using a sql datareader
and a datalist. I want to have one column display either a hyperlink
or a simple test string based on the values in one of the data
fields. I have tried many combinations of code but cannot get it to
work. My current code is listed below. From searching google I
believe thast the DataRowView type works only with a datagrid. Any
suggestions are appreciated

This is a classic asp newsgroup. While you may be lucky enough to find a
dotnet-savvy person here who can answer your question, you can eliminate the
luck factor by posting your question to an appropriate group. I suggest
microsoft.public.dotnet.framework.aspnet. or
microsoft.public.dotnet.framework.adonet.

Bob Barrows
 
M

[MSFT]

Hi Wayne,

For such a ASP.NET question, you had better send to

microsoft.public.dotnet.framework.aspnet

A short answer to the question isyou should use
DataBinder.Eval(Container.DataItem, "FieldName") in the HTML code, for
example:

<ItemTemplate>
<li>
<asp:Label ID="lblSiteName" runat=server ForeColor=Blue
text='<%# "http://"+ DataBinder.Eval(Container.DataItem, "Name")%>'>
</asp:Label>
</li>
</ItemTemplate>

If you need more detail information on this, I suggest you may send this
question to

microsoft.public.dotnet.framework.aspnet

I can guarantee you will get answer there.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top