Click here to Skip to main content
13,202,873 members (57,482 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hello all,
I have a repeater control as below, and I want to show the image button when users selected any other values other than the default Select value.
<asp:Repeater ID="rptSearchUser" runat="server">
                            Add Users</h4>
                        <div class="posSharingUsrList">
                            <div class="pull-left">
                                <asp:Label ID="lblUsername" runat="server" Text='<%#Eval("USER_NAME") %>'></asp:Label>
                            <div class="pull-left selectDiv">
                                <asp:DropDownList ID="ddlUserRoles" runat="server">
                                    <asp:ListItem Value="0">Select Role</asp:ListItem>
                                    <asp:ListItem>Full Control</asp:ListItem>
                                    <asp:ListItem>View only</asp:ListItem>
                            <div class="pull-right">
                                <asp:ImageButton ID="iBtnShareWithUser" runat="server" CommandArgument='<%#Eval("EMP_ID")%>'
                                    ImageUrl="~/Images/GreenCircle.png" OnClick="iBtnShareWithUser_Click" CssClass="imgPlus" />
                            <div class="clearfix">

I have tried the following jQuery code to show and hide the image button, but the problem is, if we selected an item from dropdown list, all of the images will display, if the repeater repeats more than one item.

$(function () {
            $("[id$='ddlUserRoles']").change(function () {
                if (this.value !== "0") {
                } else {

I tried to replace the Image button id with its class, but no luck. How I can get this worked without using autopostback event? Because, I'm using this repeater control inside Bootstrap Modal Popup. I have created a jsbin, if needed for testing.

Posted 10-Feb-13 21:12pm
Irbaz Haider Hashmi 11-Feb-13 3:58am
Try adding dropdown on change function in Repeater OnItemDataBound Event.
Pass Exact values to the Javascript function of the controls you want to show and hide with that particular dropdown.
Ravimallya 12-Feb-13 0:09am
Yeah, Okay. will try to do that. But, if anyone found a jquery solution, that would be great.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You can traverse through the control with the help of next().Please have a look on the following example.I have created this by keeping your jsbn example in mind.
$(function () {
 $("select").change(function() {
    if (this.value !== "0") {
    } else {

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171020.1 | Last Updated 15 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100