Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Highlight an item in a repeater control

Status
Not open for further replies.

RSfromCO

Programmer
Joined
May 3, 2002
Messages
149
Location
US
I am displaying the results of a database query in a repeater control. I am using alternating item templates so that the background color alternates with each row from the query. That is working nicely.

I would like to "Highlight" one row in the list. This row would be the one whose data item (Building_ID) matches the parameter that was sent to the page when it was loaded.

I tried this code to make the matching item Yellow instead of Blue...

<ItemTemplate>
<tr bgcolor=
<%
If (Request.QueryString(&quot;selected_building&quot;)= Container.DataItem(&quot;building_id&quot;) ) Then
Response.Write(&quot;Yellow&quot;)
Else
Response.Write(&quot;Blue&quot;)
End If
%>
>
<td><%#Container.DataItem(&quot;building_id&quot;)%></td>
<td><%#Container.DataItem(&quot;address&quot;)%></td>
<td><%#Container.DataItem(&quot;city&quot;)%></td>
<td><%#Container.DataItem(&quot;state&quot;)%></td>
</tr>
</ItemTemplate>


I get an error saying that Container is not declared, yet it seems to know what Container.DataItem(&quot;building_id&quot;) is when it displays the data. (if I take out the IF statement that is trying to set the background color).

I might understand this better if I knew what the # is for before the Container.DataItem objects.

Any suggestions ?
 
This is certainly possible, but you might be able to pull this off by using a DataGrid and handling the OnSelectedItem event rather than using a Repeater. It'll be less code and less headache.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top