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:
<aspataList 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>
<aspataList 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>
</aspataList>
</td>
</tr>
</ItemTemplate>
</aspataList>
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;}
}
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:
<aspataList 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>
<aspataList 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>
</aspataList>
</td>
</tr>
</ItemTemplate>
</aspataList>
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;}
}