Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 851839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:29:36+00:00 2026-05-15T07:29:36+00:00

I have a ListView inside a FormView that, for some strange reason, doesn’t fire

  • 0

I have a ListView inside a FormView that, for some strange reason, doesn’t fire neither the ItemInsert nor the ItemCommand event.
I’m populating the ListView with a generic list. I bind the list to the ListView on the OnPreRenderComplete.

    <asp:ListView runat="server" ID="lvReferences" DataKeyNames="idReference" OnItemInserting="ContractReferences_Inserting" OnItemDeleting="ContractReferences_Deleting" InsertItemPosition="LastItem" OnItemCommand="ContractReferences_Command" OnItemCreated="ContractReferences_ItemDataBound">                                    
    <LayoutTemplate>
        <ul>       
                <asp:PlaceHolder ID="itemPlaceholder" runat="server" />
        </ul>                                   
    </LayoutTemplate>
    <ItemTemplate>
        <li class="obsItem">
            <a href="#"><asp:TextBox ID="valRef" runat="server" Width="5px" Enabled="false" Text='<%#Bind("idProcessRecordRef") %>' /></a>                                    
            <asp:TextBox id="txtRef" runat="server" Text='<%#Bind("description") %>' />
            <asp:ImageButton ID="btDelete" runat="server" CommandName="Delete" ImageUrl="~/_layouts/web.commons/Images/eliminar.png" />
        </li>
    </ItemTemplate> 
    <InsertItemTemplate>
        <li class="obsItem">
            <a href="#"><asp:TextBox ID="valRef" runat="server" Width="5px" Enabled="false" /></a>                                    
            <asp:TextBox id="txtRef" runat="server" />
            <asp:ImageButton ID="btDetail" CausesValidation="false" OnClientClick="javascript:openPopup();return false;" runat="server" ImageUrl="~/_layouts/web.commons/Images/novo.png" />
            <asp:ImageButton ID="btSaveDs" runat="server" CommmandName="Insert" CausesValidation="false" ImageUrl="~/_layouts/web.commons/Images/gravarObs.png" />
        </li>
    </InsertItemTemplate>
</asp:ListView>   

My ItemDataBound method is:

    protected void ContractReferences_ItemDataBound(object sender, ListViewItemEventArgs e)
    {
        if (!IsPostBack)
        {
            TextBox valRef = e.Item.FindControl("valRef") as TextBox;
            TextBox txtRef = e.Item.FindControl("txtRef") as TextBox;
            ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "function openPopup(){ window.open('ContractPicker.aspx?c1=" + valRef.ClientID + "&c2=" + txtRef.ClientID + "');}", true);
        }
    }

So, basically, in the InsertItemTemplate I put a button that opens a LOV and populates my valRef and txtRef fields. I had to put a “return false” in order for the parent page to not postback (and I think the problem lies here…).
Then, when I click in the ImageButton with the CommandName=”Insert”, instead of firing the ItemCommand event, it enters once again in the ItemDataBound handler.

So, any ideas?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T07:29:37+00:00Added an answer on May 15, 2026 at 7:29 am

    Well, after searching for a few days, I found out this is a known bug.
    http://connect.microsoft.com/VisualStudio/feedback/details/328680/problem-accessing-controls-clientid-on-asp-net-listviews-itemcreated

    So, it hasn’t nothing to do with the popup, but with the ListView and the ItemDataBound itself. I put the ItemDataBound logic on the OnLoad (using a recursive FindControl), and it worked.
    So, in the ItemDataBound, the ClientID of my controls is “wrong”.
    Stupid bug really…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can we have ExpandableListView inside ListView so that I can have group level first
I have a ListView inside a AlertDialog, the problem I am having is that
I have a WPF ListView inside StackPanel, with Height=Auto. It's great that it does
I have a WPF ListView inside StackPanel, with Height=Auto. It's great that it does
I have a ListView with a checkbox field inside that gets the id set
I would have listview and a lot of items inside. I want that user
Possible Duplicate: Getting value of a PasswordBox that's inside a ListView I have a
I have a ListView that I'm populating from a custom ListAdapter . Inside the
I have Activity with ListView inside it and in the onCreate method of the
I have a ListView with EditText inside. Actually, when i touch an element of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.