Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Making a controls ID property inside a repeater controls ItemTemplate the value of the ItemIndex?

Reply
Thread Tools

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

 
 
Andy B
Guest
Posts: n/a
 
      11-15-2008
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 aspanel 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.


 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      11-15-2008
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>
<aspanel ID="p" runat="server" style="display:none;">
hello
</aspanel>
</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 aspanel 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.
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
if statement inside Repeater ItemTemplate Oleg ASP .Net 1 03-07-2008 03:53 PM
How to find which button was clicked in a repeater itemtemplate and find the value of textbox AlecL ASP .Net 3 04-11-2007 10:52 PM
Getting reference to controls within ItemTemplate in a repeater AC [MVP MOSS] ASP .Net 2 02-13-2007 04:25 AM
Accessing Repeater's DataSource from a UserControl inside the ItemTemplate digitaljeebus@gmail.com ASP .Net Web Controls 0 06-13-2006 07:58 PM
can code inside a Repeater's ItemTemplate modify controls in the ItemTemplate? Bennett Haselton ASP .Net 1 09-24-2004 01:59 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57