asp.net - export gridview to excel is not working with Ajax and Update panel -


i have grid-view in update panel. there link button inside grid-view fire export command in row command event. there grid-view exported on command code. debug, pointers goes in export not happening. know missing here, not able after spending lot of hours. script manager on master page.

can 1 please. below code.

  <asp:updatepanel id="updatepanel2" runat="server">                 <contenttemplate>                 <asp:gridview id="grd_report" runat="server" showfooter="true" cssclass="ui-jqgrid-btable table-hover" autogeneratecolumns="false" allowpaging ="true" pagesize ="12"  >                 <columns>                  <asp:templatefield headertext="name">                 <itemtemplate>                 <asp:label id="lbl_campaignname" runat="server" text='<%#eval("name") %>'></asp:label>                 </itemtemplate>                 <itemstyle width="100px" />                 <headerstyle width="100px" />                 </asp:templatefield>                  <asp:templatefield headertext="createdate">                 <itemtemplate>                 <asp:label id="lbl_createdate" runat="server" text='<%#eval("createdate") %>'></asp:label>                 </itemtemplate>                 <itemstyle width="130px" />                 <headerstyle width="130px" />                 </asp:templatefield>                   <asp:templatefield headertext="sender">                 <itemtemplate>                 <asp:label id="lbl_senderid" runat="server" text='<%#eval("sender") %>'></asp:label>                 </itemtemplate>                 <itemstyle width="85px" />                 <headerstyle width="85px" />                 </asp:templatefield>                   <asp:templatefield headertext="text">                 <itemtemplate>                 <asp:label id="lbl_text" runat="server" text='<%#eval("text") %>'></asp:label>                 </itemtemplate>                 <footertemplate>                 <asp:dropdownlist class="ui-pg-selbox" id="drp_itemcount" runat="server" autopostback="true"                         onselectedindexchanged="drp_itemcount_selectedindexchanged" >                 <asp:listitem>10</asp:listitem>                 <asp:listitem>15</asp:listitem>                 <asp:listitem>50</asp:listitem>                 <asp:listitem>100</asp:listitem>                 <asp:listitem>200</asp:listitem>                 </asp:dropdownlist>                 </footertemplate>                  <itemstyle width="375px" />                 <headerstyle width="375px" />                 <footerstyle horizontalalign="center"  />                 </asp:templatefield>                   <asp:templatefield headertext="count">                 <itemtemplate>                 <asp:label id="lbl_smscount" runat="server" text='<%#eval("count") %>'></asp:label>                 </itemtemplate>                 <itemstyle horizontalalign="center" width="80px" />                 <headerstyle width="80px" />                 </asp:templatefield>                   <asp:templatefield headertext="delivery count">                 <itemtemplate>                 <table class="deliverycount">                 <tr>                 <td style="padding:5px;width:180px" colspan="2">total: <%#eval("total")%></td>                 </tr>                  <table style="font-size:11px;width:180px;">                 <tr>                 <td style="padding:5px;font-size:11px;width:80px">a: <%#eval("a")%></td>                 <td style="padding:5px;font-size:11px;width:80px">b: <%#eval("b")%></td>                 </tr                      <tr>                 <td style="padding:5px;font-size:11px;width:80px">2: <%#eval("2")%></td>                 <td style="padding:5px;font-size:11px;width:80px">1: <%#eval("1")%></td>                 </tr>                  </table>                   </itemtemplate>                 </asp:templatefield>                    <asp:templatefield headertext="download">                 <itemtemplate>                 <asp:linkbutton runat="server" id="lnk_download" style="font-size:11px;" commandname="download" commandargument='<%#eval("campaignid") %>' text="download"  class="ui-icon-document"></asp:linkbutton>                 </itemtemplate>                 <itemstyle horizontalalign="center" width="100px" />                 <headerstyle width="100px" />                 </asp:templatefield>                    </columns>                 <headerstyle horizontalalign="center" font-size="13" font-bold="true"  />                 <rowstyle font-names="helvetica" font-size="10" />                 <pagerstyle cssclass ="gridviewpager" height="30px" />                 </asp:gridview>                 </contenttemplate>                 <triggers>                 <asp:asyncpostbacktrigger controlid="grd_export" eventname="rowcommand" />                 </triggers>                 </asp:updatepanel>    <asp:updatepanel id="updatepanel6" runat="server">    <contenttemplate>    <asp:gridview id="grd_export" runat="server" visible="false" autogeneratecolumns ="false" > <columns>  <asp:templatefield headertext="name"> <itemtemplate> <asp:label id="lbl_name" runat="server" text='<%#eval("name") %>'></asp:label> </itemtemplate> </asp:templatefield>  <asp:templatefield headertext="number"> <itemtemplate> <asp:label id="lbl_number" runat="server" text='<%#eval("number") %>'></asp:label> </itemtemplate> </asp:templatefield>  <asp:templatefield headertext="id"> <itemtemplate> <asp:label id="lbl_id" runat="server" text='<%#eval("id") %>'></asp:label> </itemtemplate> </asp:templatefield>  <asp:templatefield headertext="text"> <itemtemplate> <asp:label id="lbl_text" runat="server" text='<%#eval("text") %>'></asp:label> </itemtemplate> </asp:templatefield>  <asp:templatefield headertext="text id"> <itemtemplate> <asp:label id="lbl_messageid" runat="server" text='<%#eval("textid") %>'></asp:label> </itemtemplate> </asp:templatefield>  <asp:templatefield headertext="date"> <itemtemplate> <asp:label id="lbl_date" runat="server" text='<%#eval("date") %>'></asp:label> </itemtemplate> </asp:templatefield>  <asp:templatefield headertext="status"> <itemtemplate> <asp:label id="lbl_status" runat="server" text='<%#eval("status") %>'></asp:label> </itemtemplate> </asp:templatefield>  <asp:templatefield headertext="credits"> <itemtemplate> <asp:label id="lbl_credits" runat="server" text='<%#eval("credits") %>'></asp:label> </itemtemplate> </asp:templatefield>  </columns> </asp:gridview>    </contenttemplate>     </asp:updatepanel> 

below code on row command event

 if e.commandname = "download"         dim str string         str = " select * [box]   msgid='" + e.commandargument + "'"         dim com new sqlcommand(str, con)         dim da new sqldataadapter(com)         dim dt new datatable         da.fill(dt)          if not dt nothing             if dt.rows.count > 0                 grd_export.datasource = dt                 grd_export.databind()                 grd_export.visible = true                 response.clear()                 response.cache.setcacheability(httpcacheability.nocache)                 response.addheader("content-disposition", "attachment;filename=message.xls")                 response.charset = ""                 response.contenttype = "application/vnd.xls"                 me.enableviewstate = false                 dim stringwrite system.io.stringwriter = new system.io.stringwriter                 dim htmlwrite system.web.ui.htmltextwriter = new system.web.ui.htmltextwriter(stringwrite)                 grd_export.rendercontrol(htmlwrite)                 response.write(stringwrite.tostring())                 grd_export.visible = false                 response.end()               end if         end if      end if 

you need add postback trigger update panel respose.write work.


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -