Click here to Skip to main content
12,998,483 members (123,190 online)
Rate this:
Please Sign up or sign in to vote.
See more:
<asp:DataList ID="DataList1" runat="server" DataKeyField="id" onitemdatabound="DataList1_ItemDataBound1"
<p><b><%#Container.ItemIndex+1 %></b></p>
<asp:Literal ID="Literal1" runat="server" Text='<%# Server.HtmlDecode(Eval("question").ToString()) %>'></asp:Literal></b></p>

<div class="ans">
<asp:DataList ID="DataList2" runat="server" RepeatDirection="Horizontal" RepeatColumns="4" >
<asp:Literal ID="Literal2" runat="server" Text='<%# Server.HtmlDecode(Eval("A1").ToString()) %>'></asp:Literal></b></p>
<asp:Literal ID="Literal3" runat="server" Text='<%# Server.HtmlDecode(Eval("A2").ToString()) %>'></asp:Literal></b></p>
<asp:Literal ID="Literal4" runat="server" Text='<%# Server.HtmlDecode(Eval("A3").ToString()) %>'></asp:Literal></b></p>
<asp:Literal ID="Literal5" runat="server" Text='<%# Server.HtmlDecode(Eval("A4").ToString()) %>'></asp:Literal></b></p>
<asp:Label ID="lblAnswer" runat="server" Text='<%# Eval("CorrectAnswer") %>'></asp:Label></b></p>


Source code:
protected void DataList1_ItemDataBound1(object sender, DataListItemEventArgs e)
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
DataList d1 = (DataList)e.Item.FindControl("DataList2");
d1.Visible = true;

Label lanswer = (Label)e.Item.FindControl("lblAnswer");
if (lanswer != null)
lanswer.CssClass = "correct";


In this, in nested datalist i have a label(lblAnswer) to display correct answer for which i want it to be highlighted.. but im not getting desired output please provide the solution.
Posted 29-Jan-13 19:47pm
Updated 30-Jan-13 16:12pm
Sheikh Muhammad Haris 30-Jan-13 22:11pm
Where is the question ?
Sheikh Muhammad Haris 30-Jan-13 22:11pm
Oh .. I found it ... you have added it inside your code blocks :)

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Im sorry i may be in-correct but would

TD              {font-family: Arial; font-size: 10pt; text-align: center;}
DIV                 {font-family: Arial; font-size: 9pt;}
TH              {font-family: Arial; font-size: 10pt; text-align: center;}

Help ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170622.1 | Last Updated 30 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100