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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy B

    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.


  • bruce barker

    #2
    Re: Making a controls ID property inside a repeater controls ItemTemplatethe value of the ItemIndex?

    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.getEle mentById(e);
    e.style.display = e.style.display == 'block' ? 'none' : 'block';
    }
    </script>
    <asp:Repeater ID="rpt" runat="server" >
    <ItemTemplate >
    <div>
    <asp:HyperLin k runat="server"
    Text="click me"
    NavigateUrl='<% # "javascript:doi t(\""
    + Container.FindC ontrol("p").Cli entID
    + "\");" %>'
    />
    </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.
    >
    >

    Comment

    Working...