hi want make footertemplate can expand , collapse results image example in other topic: how add footertemplate gridview boundfields
i want default show 1 result, , after clicking in icon on footertemplate show me more results 4 or 5, can show code, in advance.
the same work have done on project! pasting work here. please go through it, might solving problem
aspx:
<asp:gridview width="100%" border="1" id="gwprofit" rowstyle-wrap="true" runat="server" autogeneratecolumns="false" alternatingrowstyle-cssclass="alternaterow" rowstyle-verticalalign="bottom" showfooter="true" headerstyle-wrap="true" onrowcommand="gwprofit_rowcommand" onrowdatabound="gwprofit_rowdatabound"> <columns> <asp:templatefield headertext="start date"> <itemtemplate> <div class="input-append"> <asp:textbox class="input_disabled" id="txtstartdate" runat="server" width="110px" height="22px" text='<%# bind("startdate","{0}") %>'> </asp:textbox> <button class="btn123" id="imgstartdate" runat="server" type="button" style="height:25px;"> <i class="icon-calendar"></i> </button> </div> <ajaxtoolkit:calendarextender id="startdate" runat="server" targetcontrolid="txtstartdate" popupbuttonid="imgstartdate" format="dd-mmm-yyyy"> </ajaxtoolkit:calendarextender> </itemtemplate> <footertemplate> <asp:textbox class="input_disabled" id="txtnewstartdate" runat="server" width="110px" height="22px"> </asp:textbox> <button class="btn123" id="imgstartdate" runat="server" type="button" style="height:25px;"> <i class="icon-calendar"></i> </button> </div> <ajaxtoolkit:calendarextender id="startdate" runat="server" targetcontrolid="txtnewstartdate" popupbuttonid="imgstartdate" format="dd-mmm-yyyy"> </ajaxtoolkit:calendarextender> </footertemplate> </asp:templatefield> <asp:templatefield headertext="end date"> <itemtemplate> <asp:textbox class="input_disabled" id="txtenddate" runat="server" width="110px" height="22px" text='<%# bind("enddate","{0}") %>'> </asp:textbox> <button class="btn123" id="imgenddate" runat="server" type="button" style="height:25px;"> <i class="icon-calendar"></i> </button> <ajaxtoolkit:calendarextender id="enddate" runat="server" targetcontrolid="txtenddate" popupbuttonid="imgenddate" format="dd-mmm-yyyy"> </ajaxtoolkit:calendarextender> </itemtemplate> <footertemplate> <asp:textbox class="input_disabled" id="txtnewenddate" runat="server" width="110px" height="22px"> </asp:textbox> <button class="btn123" id="imgenddate" runat="server" type="button" style="height:25px;"> <i class="icon-calendar"></i> </button> <ajaxtoolkit:calendarextender id="enddate" runat="server" targetcontrolid="txtnewenddate" popupbuttonid="imgenddate" format="dd-mmm-yyyy"> </ajaxtoolkit:calendarextender> </footertemplate> </asp:templatefield> <asp:templatefield headertext="profit per unit"> <itemtemplate> <asp:textbox class="input_disabled" id="txtprofitperunit" width="100px" height="22px" runat="server" text='<%# bind("profitperunit","{0}") %>'> </asp:textbox> </itemtemplate> <footertemplate> <asp:textbox class="input_disabled" id="txtnewprofitperunit" width="100px" height="22px" runat="server" text="0"/> </footertemplate> </asp:templatefield> <asp:templatefield headertext="action" controlstyle-width="14px" footerstyle-width="14px"> <itemtemplate> <input type="hidden" id="txtrec_status" name="txtrec_status" runat="server"/> <asp:imagebutton id="btndelete" runat="server" commandname="delete" imageurl="~/images/delete.gif" alternatetext="delete" commandargument="<%# ((gridviewrow) container).rowindex%>" usesubmitbehavior="false" /> </itemtemplate> <footertemplate> <asp:imagebutton id="btnadd" runat="server" commandname="add" imageurl="~/images/add.png" alternatetext="add" usesubmitbehavior="false"/> </footertemplate> </asp:templatefield> </columns> </asp:gridview> codebehind:
protected void gwprofit_rowcommand(object sender, gridviewcommandeventargs e) { if (viewstate["dtstartdate"] != null) dtstartdate = (datatable) viewstate["dtstartdate"]; if (e.commandname.equals("add")) { textbox txtstartdate = (textbox)gwprofit.footerrow.findcontrol("txtnewstartdate"); textbox txtenddate = (textbox)gwprofit.footerrow.findcontrol("txtnewenddate"); textbox txtprofitperunit = (textbox)gwprofit.footerrow.findcontrol("txtnewprofitperunit"); if (txtenddate.text == "" || txtstartdate.text == "" || txtprofitperunit.text == "") { scriptmanager.registerstartupscript(this, gettype(), "alert", "alert('please select start date, end date , profit per unit.')", true); } else { dtstartdate.rows.add(dtstartdate.newrow()); dtstartdate.rows[dtstartdate.rows.count - 1]["currencydeatailid"] = -2; dtstartdate.rows[dtstartdate.rows.count - 1]["startdate"] = objfunc.todate(txtstartdate.text); dtstartdate.rows[dtstartdate.rows.count - 1]["enddate"] = objfunc.todate(txtenddate.text); dtstartdate.rows[dtstartdate.rows.count - 1]["profitperunit"] = objfunc.todecimal(txtprofitperunit.text); if (dtstartdate.rows.count >= 0&&dtstartdate.rows[0]["currencydeatailid"].tostring()=="-1") { dtstartdate.rows[0].delete(); if (dtstartdate.rows.count > 0 && dtstartdate.rows[0].rowstate == datarowstate.deleted) dtstartdate.rows.removeat(0); } viewstate["dtstartdate"] = dtstartdate; profit_loadgrid(); } } else if (e.commandname.equals("delete")) { int index = objfunc.toint(e.commandargument.tostring()); gridviewrow gvr = (gridviewrow)(((imagebutton)e.commandsource).namingcontainer); int removeat = gvr.rowindex; datatable dt = new datatable(); dt = (datatable)viewstate["dtstartdate"]; dt.rows.removeat(removeat); dt.acceptchanges(); viewstate["dtstartdate"] = dt; profit_loadgrid(); } }
Comments
Post a Comment