c# - ajax with datalist giving error -


i have data list control placed inside content place holder.

<asp:content id="content3" contentplaceholderid="maincontent" runat="server">     <asp:scriptmanager id="mainscriptmanager" runat="server" />     <asp:updatepanel id="updatepanel1" runat="server">         <contenttemplate>             <asp:datalist id="dlprodocut" runat="server" repeatcolumns="3" edititemindex="-1"                 repeatdirection="horizontal" onitemdatabound="dlprodocut_itemdatabound">                 <itemtemplate>                     <asp:table id="table1" runat="server" border="0" cellspacing="0" cellpadding="0">                         <asp:tablerow>                             <asp:tablecell height="10" horizontalalign="center" verticalalign="top">                              </asp:tablecell>                         </asp:tablerow>                         <%--image--%>                         <asp:tablerow>                             <asp:tablecell height="150" width="7" horizontalalign="left" verticalalign="top">                                 <asp:hyperlink id="hyrproductimg" runat="server">                               <img alt='<%# databinder.eval(container.dataitem,"title")%>' src="../images/<%# databinder.eval(container.dataitem,"smallimage") %>" border="0" width="226" height="166" />                                 </asp:hyperlink>                             </asp:tablecell>                             <asp:tablecell width="5">  </asp:tablecell>                         </asp:tablerow>                         <%--title--%>                         <asp:tablerow>                             <asp:tablecell height="45" width="7" cssclass="product-name" horizontalalign="center"                                 verticalalign="top">                             <strong> <%# databinder.eval(container.dataitem, "title")%></strong>                             </asp:tablecell>                         </asp:tablerow>                         <%--shortdescription--%>                         <asp:tablerow>                             <asp:tablecell width="7" horizontalalign="justify" verticalalign="top" cssclass="testimonial-text">                                 <asp:label id="label1" runat="server" text='<%# databinder.eval(container.dataitem,"shortdescription")%>'></asp:label>                             </asp:tablecell>                         </asp:tablerow>                         <%--read more--%>                         <asp:tablerow>                             <asp:tablecell horizontalalign="left">                                 <asp:hyperlink id="lnkproductdetails" cssclass="read-more" runat="server">read more &rarr;</asp:hyperlink>                             </asp:tablecell>                         </asp:tablerow>                         <asp:tablerow>                             <asp:tablecell height="60" horizontalalign="justify" verticalalign="top" cssclass="testimonial-text">                              </asp:tablecell>                         </asp:tablerow>                     </asp:table>                 </itemtemplate>             </asp:datalist>         </contenttemplate>         <triggers>             <asp:asyncpostbacktrigger controlid="dlprodocut" />             <asp:asyncpostbacktrigger controlid="btnnext" />         </triggers>     </asp:updatepanel>     <asp:label id="lblpage" runat="server" text="" />     <asp:button id="btnprevious" runat="server" text="&lt;&lt;" />     <asp:button id="btnnext" runat="server" text="&gt;&gt;" onclick="btnnext_click" />     <asp:panel id="bottompager_panel" runat="server">     </asp:panel> </asp:content> 

on click of next button doing paging on control , navigating next page. on page load doing this

if (!ispostback)     {         pagecount = 1;         pageno = 1;         startpage = 6 * (pageno - 1) + 1;          lastpage = startpage + 5;          binddatalist();     } 

this code binddatalist

public void binddatalist() {      string source = configurationmanager.connectionstrings["cad-b"].tostring();     sqlconnection con = new sqlconnection(source);     sqlcommand cmd = new sqlcommand("sp_getproductpagingbymenuid", con);     //cmd.commandtype = commandtype.storedprocedure;     //cmd.commandtext = "sp_getproductpagingbymenuid";     con.open();     cmd.commandtype = commandtype.storedprocedure;     cmd.parameters.add("@startpage", startpage);     cmd.parameters.add("@lastpage", lastpage);     sqldatareader dr =    cmd.executereader();     datatable dt = new datatable();     dt.load(dr);      dlprodocut.datasource = dt;     dlprodocut.databind(); } 

on click of next button have written following code

protected void btnnext_click(object sender, eventargs e) {     dlprodocut.datasource = null;     dlprodocut.databind();     pagecount++;     pageno = pagecount;     startpage = 6 * (pageno - 1) + 1;     lastpage = startpage + 5;     binddatalist(); } 

problem facing every time shows me same content loaded first time on page. when debug code can see data list loaded new records not reflected on page tried removing caching dint help. moment removed next button trigger section giving me proper record complete page getting post dont want. removed code

<asp:asyncpostbacktrigger controlid="btnnext" /> 

please stuck since long. new technology. in advance.

try :

<triggers>  <asp:asyncpostbacktrigger controlid="datalistid$btnnext" /> </triggers> 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -