c# - How to re-bind ListView on OnClick event of a button? -


this seemed simple @ first can't work.

i have following scenario:

        <asp:listview id="commentslistview" runat="server">             <layouttemplate>                     <asp:placeholder id="itemplaceholder" runat="server" />             </layouttemplate>             <itemtemplate>                 <uc:comment runat="server" commentitem="<%# currentcomment %>" />                 <br />             </itemtemplate>         </asp:listview>         <asp:textbox id="newcomment" runat="server" />         <asp:imagebutton imageurl="/images/ball.png" runat="server"                       onclick="submitcomment" /> 

code:

    protected void page_load(object sender, eventargs e)     {          renderlistview();     }      protected void renderlistview()     {         commentslistview.datasource = //get data source objects         commentslistview.databind();     }      protected commentobject currentcomment     {         { return (commentobject)page.getdataitem(); }     }      protected void submitcomment(object sender, imageclickeventargs e)     {            //code submit comment          renderlistview();     } 

basically, when submit comment, want see in listview, don't. "mycontrol" gets null comment in post-back, of items (not new one).

only after refresh page, can see new comment i'v submitted. can't refresh page every submit because code inside updatepanel (the issue occurs without updatepanel well).

any idea how solve this?

i can't find specifics on this, have hunch user control in itemtemplate causing issue. can remove , see if works?


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -