My Gridview is not Binding in Asp.net Update Panel -


i have gridview control i'm using bind 3 different data table database working fine without updatepanel when come update panel working 1 time when click of button, again if click button button_click event executing gridview not showing new data showing old records
i'm used line code updatepanel1.update() no use
this code

<asp:updatepanel id="updatepanel1" runat="server">         <contenttemplate>        <ul class="nav nav-tabs">     <li id="licommentall" class="active" runat="server">         <asp:linkbutton id="lnkcommentall" runat="server" onclick="lnkcommentall_click">                     </asp:linkbutton>     </li>     <li id="licommentapproval" runat="server">         <asp:linkbutton id="lnkcommentapproval" runat="server" onclick="lnkcommentapproval_click">             approval         </asp:linkbutton>     </li>     <li id="licommentpending" runat="server">                <asp:linkbutton id="lnkcommentpending" runat="server" onclick="lnkcommentpending_click">             pending <asp:label id="lblpendingcount" cssclass="badge" runat="server"></asp:label>         </asp:linkbutton>     </li>        <li id="licommentspam" runat="server">         <asp:linkbutton id="lnkcommentspam" runat="server" onclick="lnkcommentspam_click">             spam         </asp:linkbutton>     </li>   </ul>      <div class="tab-content">     <div role="tabpanel" id="divcommentsubmenu" style="width:100%;">         <asp:gridview id="gridcomment" runat="server" autogeneratecolumns="false">             <columns>                 <asp:templatefield>                     <headertemplate>                         <div class="row" style="padding:20px;">                             <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">                                 <asp:checkbox id="chkparent" runat="server" />&nbsp;&nbsp;                                 <div class="btn-group btn-group-xs" role="group" aria-label="...">                                     <asp:button id="btnapprove" runat="server" cssclass="btn btn-primary" text="approve" onclick="btnapprove_click" />                                     <asp:button id="btnspam" runat="server" cssclass="btn btn-primary" text="spam" onclick="btnspam_click" />                                     <asp:button id="btndelete" runat="server" cssclass="btn btn-primary" text="delete" onclick="btndelete_click" />                                 </div>                                                              </div>                             <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">                             <div class="dropdown" style="margin-top:10px; float:right;">                                <button class="btn btn-default dropdown-toggle btn-xs" type="button" id="dropdownmenucommentdate" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">                                 search comment                                 <span class="caret"></span>                                </button>                                <ul class="dropdown-menu" aria-labelledby="dropdownmenucommentdate">                                 <li>                                     <asp:linkbutton id="lnktoday" runat="server">today</asp:linkbutton>                                 </li>                                 <li>                                     <asp:linkbutton id="lnkyesterday" runat="server">yesterday</asp:linkbutton>                                 </li>                                 <li>                                     <asp:linkbutton id="lnkthisweek" runat="server">                                         week&nbsp;&nbsp;<asp:label id="lblthisweek" runat="server"></asp:label>                                     </asp:linkbutton>                                 </li>                                 <li>                                     <asp:linkbutton id="lnklastweek" runat="server">                                         last week&nbsp;&nbsp;<asp:label id="lbllastweek" runat="server"></asp:label>                                     </asp:linkbutton>                                 </li>                                 <li role="separator" class="divider"></li>                                 <li>                                     <asp:linkbutton id="lnkthismonth" runat="server">                                         month&nbsp;&nbsp;<asp:label id="lblthismonth" runat="server"></asp:label>                                     </asp:linkbutton>                                 </li>                                 <li>                                     <asp:linkbutton id="lnklastmonth" runat="server">                                         last month&nbsp;&nbsp;<asp:label id="lbllastmonth" runat="server"></asp:label>                                     </asp:linkbutton>                                 </li>                                 <li role="separator" class="divider"></li>                                 <li><a id="acr" href="javascript:void(0);">custom range</a></li>                                 <li id="licustomranger" style="display:none;">                                     <ul style="list-style-type:none; margin-left:-40px;">                                         <li>                                             <asp:textbox id="txtfrom" runat="server" cssclass="form-control input-sm" placeholder="from date {yyyy-mm-dd}"></asp:textbox>                                         </li>                                         <li>                                             <asp:textbox id="txtto" runat="server" cssclass="form-control input-sm" placeholder="to date {yyyy-mm-dd}"></asp:textbox>                                         </li>                                         <li>                                             <asp:button id="btncustomrange" runat="server" text="search" cssclass="btn btn-primary btn-xs" />                                         </li>                                     </ul>                                 </li>                               </ul>                             </div>                             </div>                         </div>                                                                  </headertemplate>                     <itemtemplate>                         <div class="row" style="padding:15px; margin-top:2px;">                             <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">                               <asp:label id="commentid" runat="server" visible="false" text='<%# eval("commentid") %>'></asp:label>                               <asp:checkbox id="chkchild" runat="server" />&nbsp;&nbsp;&nbsp;                               <asp:hyperlink id="hpkposttitle" runat="server" text='<%# eval("posttitle") %>' navigateurl='<%# getrouteurl("routetogeneralsite", new { postid = eval("postid").tostring(), title = userfriendlyurl.seourl(eval("posttitle").tostring()) }) %>'></asp:hyperlink>                             </div>                             <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">                               <table>                                   <tr>                                       <td rowspan="4" style="vertical-align:top;padding:5px;">                                           <asp:image id="commentuserimage" runat="server" cssclass="img-rounded" width="35px" height="35px" imageurl='<%# getrouteurl("routetoprofilepicimage", new {userid=eval("userid").tostring(), username=extension.decrypt(eval("username").tostring()) }) %>' />                                       </td>                                       <td colspan="3" style="padding-left:10px;">                                           <font color="blue"><strong><asp:label id="commentuserfullname" runat="server" text='<%# eval("fullname") %>'></asp:label></strong></font>                                           <span style="float:right;"><%# string.format("{0:dddd, dd mmm yyyy}", eval("commentdate")) %> </span>                                       </td>                                   </tr>                                   <tr>                                       <td style="width:100%; padding-left:10px;">                                           <asp:label id="lblcommentmessage" runat="server" text='<%# eval("commentmessage") %>'></asp:label><br />                                           <a href="javascript:void(0);" onclick="showedit(<%# eval("commentid") %>); return false;">edit</a>&nbsp;&nbsp;<a href="javascript:void(0);" onclick="showreply(<%# eval("commentid") %>); return false;">reply</a><br />                                           <div id='divedit<%# eval("commentid") %>' style="display:none;">                                            <asp:textbox id="txtedit" runat="server" cssclass="form-control" textmode="multiline" text='<%# eval("commentmessage") %>'></asp:textbox>                                            <asp:button id="btngridviewsaveedit" cssclass="btn btn-primary btn-xs" runat="server" text="save edit" style="margin-top:3px;"/>&nbsp;&nbsp;<a  class="btn btn-primary btn-xs" href="javascript:void(0);" onclick="closereplyedit(<%# eval("commentid") %>); return false;">close</a>                                           </div>                                           <div id='divreply<%# eval("commentid") %>' style="display:none;">                                            <asp:textbox id="txtreply" runat="server" cssclass="form-control" textmode="multiline"></asp:textbox>                                            <asp:button id="btngridviewreply" runat="server" cssclass="btn btn-primary btn-xs" text="reply" style="margin-top:3px;"/>&nbsp;&nbsp;<a  class="btn btn-primary btn-xs" href="javascript:void(0);" onclick="closereplyedit(<%# eval("commentid") %>); return false;">close</a>                                           </div>                                       </td>                                   </tr>                                   <tr>                                       <td style="padding:5px; width:100%;">                                           <asp:linkbutton id="lnkgridviewapproval" runat="server" style="padding:0 5px; font-size:12px;">                                               <span class="glyphicon glyphicon-ok" aria-hidden="true"></span>&nbsp;approve                                           </asp:linkbutton>                                           <asp:linkbutton id="lnkgridviewspam" runat="server" style="padding:0 5px; font-size:12px;">                                               <span class="glyphicon glyphicon-ban-circle" aria-hidden="true"></span>&nbsp;spam                                           </asp:linkbutton>                                           <asp:linkbutton id="linkbutton1" runat="server" style="padding:0 5px; font-size:12px;">                                               <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>&nbsp;delete                                           </asp:linkbutton>                                       </td>                                   </tr>                               </table>                                                           </div>                         </div>                     </itemtemplate>                 </asp:templatefield>             </columns>             <headerstyle cssclass="gridheader" />         </asp:gridview>     </div>   </div>                 </contenttemplate>         <triggers>             <asp:asyncpostbacktrigger controlid="lnkcommentall" eventname="click" />             <asp:asyncpostbacktrigger controlid="lnkcommentapproval" eventname="click" />             <asp:asyncpostbacktrigger controlid="lnkcommentpending" eventname="click" />             <asp:asyncpostbacktrigger controlid="lnkcommentspam" eventname="click" />         </triggers>     </asp:updatepanel> 

c# coding :

private void bindgrid()         {             dataset ds = _commentpresenter.showallcommentbyuserid(session["uid"].tostring());             if (ds.tables[0].rows.count > 0)             {                 gridcomment.datasource = ds;                 gridcomment.databind();                 //updatepanel1.update();             }             else             {                 gridcomment.emptydatatext = "no comments show";                 gridcomment.databind();                 //updatepanel1.update();             }         }   protected void lnkcommentall_click(object sender, eventargs e)         {             bindgrid();             licommentall.attributes.add("class", "active");             licommentapproval.attributes.add("class", "");             licommentpending.attributes.add("class", "");             licommentspam.attributes.add("class", "");             scriptmanager.registerstartupscript(this, gettype(), "like", "var prm = sys.webforms.pagerequestmanager.getinstance();   prm.add_endrequest(function() {  bindjavascript(); like();  }); ", true);         }          protected void lnkcommentapproval_click(object sender, eventargs e)         {             dataset ds = _commentpresenter.showallapprovalcomment(session["uid"].tostring());             if (ds.tables[0].rows.count > 0)             {                 gridcomment.datasource = ds;                 gridcomment.databind();                 licommentall.attributes.add("class", "");                  licommentapproval.attributes.add("class", "active");                 licommentpending.attributes.add("class", "");                 licommentspam.attributes.add("class", "");                             }             else             {                 gridcomment.emptydatatext = "no comments show";                 gridcomment.databind();                                 licommentall.attributes.add("class", "");                 licommentapproval.attributes.add("class", "active");                 licommentpending.attributes.add("class", "");                 licommentspam.attributes.add("class", "");             }             scriptmanager.registerstartupscript(this, gettype(), "like", "var prm = sys.webforms.pagerequestmanager.getinstance();   prm.add_endrequest(function() {  bindjavascript(); like();  }); ", true);         }          protected void lnkcommentpending_click(object sender, eventargs e)         {             dataset ds = _commentpresenter.showallpendingcomment(session["uid"].tostring());             if (ds.tables[0].rows.count > 0)             {                 gridcomment.datasource = ds;                 gridcomment.databind();                 licommentall.attributes.add("class", "");                 licommentapproval.attributes.add("class", "");                 licommentpending.attributes.add("class", "active");                 licommentspam.attributes.add("class", "");             }             else             {                 gridcomment.emptydatatext = "no comments show";                 gridcomment.databind();                                 licommentall.attributes.add("class", "");                 licommentapproval.attributes.add("class", "");                 licommentpending.attributes.add("class", "active");                 licommentspam.attributes.add("class", "");             }             scriptmanager.registerstartupscript(this, gettype(), "like", "var prm = sys.webforms.pagerequestmanager.getinstance();   prm.add_endrequest(function() {  bindjavascript(); like();  }); ", true);         }          protected void lnkcommentspam_click(object sender, eventargs e)         {             dataset ds = _commentpresenter.showallspamcomment(session["uid"].tostring());             if (ds.tables[0].rows.count > 0)             {                 gridcomment.datasource = ds;                 gridcomment.databind();                 licommentall.attributes.add("class", "");                 licommentapproval.attributes.add("class", "");                 licommentpending.attributes.add("class", "");                 licommentspam.attributes.add("class", "active");             }             else             {                 gridcomment.emptydatatext = "no comments show";                 gridcomment.databind();                 licommentall.attributes.add("class", "");                 licommentapproval.attributes.add("class", "");                 licommentpending.attributes.add("class", "");                 licommentspam.attributes.add("class", "active");             }             scriptmanager.registerstartupscript(this, gettype(), "like", "var prm = sys.webforms.pagerequestmanager.getinstance();   prm.add_endrequest(function() {  bindjavascript(); like();  }); ", true);         } 


Comments