Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
XML
Design:
<asp:DataList ID="DataList1" runat="server" DataKeyField="id" onitemdatabound="DataList1_ItemDataBound1"
>

<ItemTemplate>
<p><b><%#Container.ItemIndex+1 %></b></p>
<p><b>
<asp:Literal ID="Literal1" runat="server" Text='<%# Server.HtmlDecode(Eval("question").ToString()) %>'></asp:Literal></b></p>


<div class="ans">

<table>
<tr>
<td>
<asp:DataList ID="DataList2" runat="server" RepeatDirection="Horizontal" RepeatColumns="4" >
<ItemTemplate>
<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>


</ItemTemplate>

</asp:DataList>

</td>
</tr>

</table>
</div>
</ItemTemplate>


</asp:DataList>

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
Updated 30-Jan-13 16:12pm
v2
Comments
[no name] 30-Jan-13 22:11pm    
Where is the question ?
[no name] 30-Jan-13 22:11pm    
Oh .. I found it ... you have added it inside your code blocks :)

1 solution

Im sorry i may be in-correct but would

CSS
<style>
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;}
</style>



Help ?
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900