LinkButton in a Repeater in a Multiview in an UpdatePanel!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xMetalDetectorx
    New Member
    • Oct 2008
    • 44

    #1

    LinkButton in a Repeater in a Multiview in an UpdatePanel!

    I am having trouble with the postbacks that are fired within my updatepanel by the linkbuttons. Here is the structure of my page:

    UpdatePanel
    MultiView
    View1
    /View1
    View2
    Repeater
    LinkButtons being generated here
    /Repeater
    /View2
    /MultiView
    /UpdatePanel

    Here is my link button code

    Code:
    <asp:LinkButton ID="lnkSelect" runat="server" OnClick="SelectOrganization"  CommandName="OrgID">SELECT</asp:LinkButton>
    Whenever I click on any of the LinkButtons that are generated, it does a Postback in the UpdatePanel. But the OnClick function is not being called. It just does the void Page_Load() function. That's it.

    The controls in my other views work fine, but I'm having trouble with these controls. I think it has to do with them being generated by the Repeater.

    Has anyone run into this problem before? Thanks in advance!
  • xMetalDetectorx
    New Member
    • Oct 2008
    • 44

    #2
    Update:

    I made these changes to my code after reading up on Repeaters and Events.

    Code:
    <asp:Repeater ID="Repeater1" runat="server" OnItemCommand="SelectOrganization">
    
    <ItemTemplate>
    
    <asp:LinkButton ID="lnkSelect" runat="server" CommandName="OrgID" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "OrgID")%>'>SELECT</asp:LinkButton>
    
    </ItemTemplate>
    
    </asp:Repeater>

    and in the code behind:

    Code:
    protected void SelectOrganization(object sender, RepeaterCommandEventArgs e)
        {
    
            lblInfo.Text = "You picked: " + e.CommandArgument.ToString(); //This label is right below the repeater, inside the UpdatePanel
        }
    Found a workaround:

    1) The problem arose from the Postback of the LinkButtons. The Postback made all the info in the repeater vanish (because i turned off Viewstate at Application level)

    2) On PageLoad i have to databind() the Repeater again in order for it to work.


    The problem here is the Repeater gets its values from the DB. So if I have to Databind it again on page_load, that is essentially making 2 DB calls! =(

    I tried enabling the viewstate of just the repeater, but that didn't help. Any other suggestions?

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      Well...if you disable ViewState I don't really see a way around calling the databind method (I would do this in the PagePrender event instead of the PageLoad event).

      Did you try enabling the ViewState for the application?
      Did this work?

      -Frinny

      Comment

      • xMetalDetectorx
        New Member
        • Oct 2008
        • 44

        #4
        If i turn on Viewstate, it works fine. I haven't found another way besides databinding it.

        Comment

        Working...