OnItemDataBound issue...

M

Maureen Black

The following code causes two letters to be highlighted at once,
so for example, if you click on Division 2 letter 'A', the letter 'A'
in Division 1 is also highlighted. I want only one letter highlighted,
and I wand the proper division number to be highlighted alone, as well.

It seems that because the letters bound to the letterList datalist in a
nested
datalist, I cannot call the onitemdatabound event on one hyperlink only,
because
they have the same name (HyperLink1)? How can I work around this issue?

Thanks in advance.





The user interface:




Division 1 A B C D E F G H I J K L M N O P Q R S T
U V W X Y Z All


Division 2 A B C D E F G H I J K L M N O P Q R S T
U V W X Y Z All




The HTML/ASP.NET code:


<asp:DataList Width="100%" ID="divList"
DataSource='<%#getDivisions()%>' OnItemCommand="getEmployeesByDivision"
RepeatDirection="Horizontal"
Runat="server" AutoGenerateColumns="False">
<ItemTemplate>
<tr>
<td width="50%" align="left">Division</td>
<td>
<asp:LinkButton id="divNumber" Text='<%#
Convert.ToInt16(DataBinder.Eval(Container.DataItem, "DivisionNumber"))
%>' Runat="server" CommandName="GetEmployees" >
</asp:LinkButton>
</td>
<td>
<asp:DataList ID="letterList" OnItemDataBound="boldLetter"
DataSource='<%#getLetters(Convert.ToInt16(DataBinder.Eval(Container.DataItem,

"DivisionNumber")))%>' Runat="server" RepeatDirection="Horizontal">
<ItemTemplate>
<asp:HyperLink Runat=server
Text='<%#DataBinder.Eval(Container.DataItem, "Letter")%>'
NavigateUrl='<%# "/Solver/Pages/Page5.aspx?id=13&division=" +
DataBinder.Eval(Container.DataItem, "DivNumber") + "&letter=" +
DataBinder.Eval(Container.DataItem, "Letter") %>' ID="Hyperlink1">
</asp:HyperLink>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
</ItemTemplate>
</asp:DataList>



The C# codebehind to highlight the letter in the user interface:


public void boldLetter(Object sender, DataListItemEventArgs e)
{
string thisAlpha= ((HyperLink)e.Item.FindControl("HyperLink1")).Text;
if (thisAlpha==alpha){
((HyperLink)e.Item.FindControl("HyperLink1")).BackColor = Color.Gray;}
}
 

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

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top