473,385 Members | 1,553 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,385 software developers and data experts.

Making a controls ID property inside a repeater controls ItemTemplate the value of the ItemIndex?

I have a repeater control with an ItemTemplate inside of it. In the
ItemTemplate, I have a div with a link that calls a javascript function to
make an asp:Panel control visible or invisible. I need to make the ID of the
panel equal to this databinding expression:
"d<%# DataBinder.Eval(Container, "ItemIndex") %>" Any ideas how to do this?
I keep getting errors about the expression is too complex for the ID
attribute, it is not a valid identifier, if the value is inclosed in quotes,
they must match and so on.
Nov 15 '08 #1
1 4626
you have two issues.

1) you can not force the rendered id of a control in repeater.
2) setting a property value to a binding expression requires the value
only be the expression

try:
<script type="text/javascript">
function doit(e) {
e = document.getElementById(e);
e.style.display = e.style.display == 'block' ? 'none' : 'block';
}
</script>
<asp:Repeater ID="rpt" runat="server" >
<ItemTemplate>
<div>
<asp:HyperLink runat="server"
Text="click me"
NavigateUrl='<%# "javascript:doit(\""
+ Container.FindControl("p").ClientID
+ "\");" %>'
/>
</div>
<asp:Panel ID="p" runat="server" style="display:none;">
hello
</asp:Panel>
</ItemTemplate>
</asp:Repeater>

-- bruce (sqlwork.com)
Andy B wrote:
I have a repeater control with an ItemTemplate inside of it. In the
ItemTemplate, I have a div with a link that calls a javascript function to
make an asp:Panel control visible or invisible. I need to make the ID of the
panel equal to this databinding expression:
"d<%# DataBinder.Eval(Container, "ItemIndex") %>" Any ideas how to do this?
I keep getting errors about the expression is too complex for the ID
attribute, it is not a valid identifier, if the value is inclosed in quotes,
they must match and so on.

Nov 15 '08 #2

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

Similar topics

6
by: Ben | last post by:
Hi I've got a problem with a custon control that inherits form the UserControl class and that used the overlib javascript library. The control works well in a standard form but when I used it in...
1
by: Bennett Haselton | last post by:
If I have this code for repeater, it gives a compilation error saying "The type or namespace name 'MyValue2' could not be found": <asp:Repeater id="MyList" runat="server"> <ItemTemplate>...
2
by: James Moore | last post by:
I've got a datagrid. One of the elements in the grid is a comma-seperated string. I'd like to split the string and create N linkbuttons, one for each element of the string. Creating the grid...
3
by: Leigh Webber | last post by:
I have an HTMLAnchor control on my aspx page. When it's not inside a repeater, it works fine. When I put it inside a repeater control, the handler never gets fired. I have a handler for the...
3
by: Manuel | last post by:
I have the following DataGrid: <asp:datagrid id="grdPackages" runat="server" AutoGenerateColumns="False" AllowSorting="True"> <Columns> <asp:BoundColumn DataField="ShipDate"...
3
by: sorCrer | last post by:
Hi All, Posted after extensive searching! I have a nested repeater control as follows: (Simplified ;-)) <table> <asp:repeater id=parent onItemDataBound=createChild> <tr><td>Level...
15
by: Arpan | last post by:
Consider the following code which retrieves data from a SQL Server 2005 DB table & displays it in a DataGrid: <script runat="server"> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)...
1
by: Dave | last post by:
I have the following ASP.NET 2.0 code (simplified here for ease): <asp:Repeater id="SearchResultsRepeater" runat="server"> <ItemTemplate> <uc:SearchResult ID="SearchResult"...
5
by: Stan SR | last post by:
Hi, I use a repeater that displays images. I need to add dynamically a jscript function on each image that use the index value of the repeater <asp:Repeater ID="ph" runat="server"...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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.