473,378 Members | 1,457 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

OnItemDataBound issue...



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(DataBind er.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")).Back Color = Color.Gray;}
}

Nov 18 '05 #1
0 695

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Antonio D'Ottavio | last post by:
Good morning, I've a problem with a dropdownlist located inside any row of a datalist, I fill both datalist and dropdownlist at runtime, the problem is with the dropdownlist infact using the event...
0
by: vincent | last post by:
Hello, How do i get the last row OnItemDataBound in Datagrid or atleast the number of rows OnItemDataBound in Datagrid? thanks Vincent
0
by: ItNerd | last post by:
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...
4
by: Anders | last post by:
Hi, I was wondering what is most efficient of the two. Is it more efficient to add server controls within the Itemtemplate and use OnItemDataBound to manipulate and databind the servercontrols. ...
2
by: jason | last post by:
i'm trying to set the commandargument property of a buttoncolumn in the DataGrid ItemBind event. it works fine in one instance, but in the latest page i've written it doesn't seem to work, and i...
2
by: Girish | last post by:
Hello all, Im wondering why my OnItemDataBound gets fired twice here. I got this sample code from somewhere online.. and when I put a break point in the method... it hits the method twice for...
1
by: rmccinc | last post by:
OK, I am running into some issues that I cant figure out a work-around. I am not going to post code cause I figured out WHY my issue is happening: -I have a datagrid, and a button that fires a...
1
by: Mikeon | last post by:
Hello! I have a problem customizing the databound controls using the OnItemDataBound event. The code below is an example of what I'm trying to do. I have a datasource and basing on the data I...
14
by: TS | last post by:
I have this custom data list control and i override the onItemDatabound event. After upgrading to vs 2005, this event is not always getting called, though it does at other times. No changes were...
0
by: Brian Lowe | last post by:
I'm in a web page and I have hierarchical data so I'm using 2 nested DataList controls. DataList1 is using a data source with rows of , , and where MoreData is a list. DataList1 has an...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.