Click here to Skip to main content
11,477,625 members (79,051 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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 29-Jan-13 20:47pm
Edited 30-Jan-13 17:12pm
v2
Comments
Sheikh Muhammad Haris at 30-Jan-13 22:11pm
   
Where is the question ?
Sheikh Muhammad Haris at 30-Jan-13 22:11pm
   
Oh .. I found it ... you have added it inside your code blocks :)

1 solution

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

Solution 1

Im sorry i may be in-correct but would

<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 ?
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 274
1 Richard Deeming 245
2 _duDE_ 165
3 Tomas Takac 150
4 Sascha Lefèvre 145
0 Sergey Alexandrovich Kryukov 7,675
1 OriginalGriff 7,246
2 Sascha Lefèvre 3,034
3 Maciej Los 2,491
4 Richard Deeming 2,305


Advertise | Privacy | Mobile
Web02 | 2.8.150520.1 | Last Updated 30 Jan 2013
Copyright © CodeProject, 1999-2015
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