asp.net - How to change submit button to update button -
i guys have 2 page on fist page have form , on second report page form values store in grid. have submit button on form page when click on edit link redirect form page can make change , update details. want when click on edit link , move form page make editing submit button change update button how can that...
here code first page:
select travelong onetravel .uk-bsp .ca-yyz .ca-yvr partial mco refund
<div id="firstform" style="margin-left: 80px" runat="server"> <table class="style1"> <tr> <td class="style13"> <asp:label id="lbltid" runat="server" text="tid"></asp:label> </td> <td class="style5"> <asp:textbox id="tbtid" runat="server"></asp:textbox> </td> <td class="style4"> <asp:requiredfieldvalidator id="rfvtid" runat="server" controltovalidate="tbtid" errormessage="enter tid" font-bold="true" forecolor="red">*</asp:requiredfieldvalidator> </td> <td class="style5"> <asp:label id="lblunusedticketamount" runat="server" text="unused ticket amount"></asp:label> </td> <td class="style11"> <asp:textbox id="tbunusedticketamount" runat="server"></asp:textbox> </td> <td> <asp:requiredfieldvalidator id="rfvunusedticketamount" runat="server" controltovalidate="tbunusedticketamount" errormessage="enter amount" font-bold="true" forecolor="red">*</asp:requiredfieldvalidator> </td> <td> <asp:dropdownlist id="ddlunusedamount" runat="server"> <asp:listitem>usd</asp:listitem> <asp:listitem>cad</asp:listitem> <asp:listitem>gbp</asp:listitem> </asp:dropdownlist> </td> </tr> <tr> <td class="style14"> <asp:label id="lblpnr" runat="server" text="pnr"></asp:label> </td> <td class="style9"> <asp:textbox id="tbpnr" runat="server"></asp:textbox> </td> <td class="style8"> <asp:requiredfieldvalidator id="rfvpnr" runat="server" controltovalidate="tbpnr" errormessage="enter pnr" font-bold="true" forecolor="red">*</asp:requiredfieldvalidator> </td> <td class="style9"> <asp:label id="lblairlinepenality" runat="server" text="airline penality"></asp:label> </td> <td class="style12"> <asp:textbox id="tbairlinepenality" runat="server"></asp:textbox> </td> <td class="style10"> <asp:requiredfieldvalidator id="rfvairlinepenality" runat="server" controltovalidate="tbairlinepenality" errormessage="enter penality" font-bold="true" forecolor="red">*</asp:requiredfieldvalidator> </td> <td class="style10"> <asp:dropdownlist id="ddlairlinepenality" runat="server" autopostback="true"> <asp:listitem>usd</asp:listitem> <asp:listitem>cad</asp:listitem> <asp:listitem>gbp</asp:listitem> </asp:dropdownlist> </td> </tr> <tr> <td class="style13"> <asp:label id="lblticketnumber" runat="server" text="ticket number"></asp:label> </td> <td class="style5"> <asp:textbox id="tbticketnumber" runat="server"></asp:textbox> </td> <td class="style4"> <asp:requiredfieldvalidator id="rfvticketnumber" runat="server" controltovalidate="tbticketnumber" errormessage="enter esac" font-bold="true" forecolor="red">*</asp:requiredfieldvalidator> </td> <td class="style5"> <asp:label id="lblnetrefundprocess" runat="server" text="net refund process"></asp:label> </td> <td class="style11"> <asp:textbox id="tbnetrefundprocess" runat="server"></asp:textbox> </td> <td> <asp:requiredfieldvalidator id="rfvnetrefundprocess" runat="server" controltovalidate="tbnetrefundprocess" errormessage="requiredfieldvalidator" font-bold="true" forecolor="red">*</asp:requiredfieldvalidator> </td> <td> <asp:dropdownlist id="ddlnetrefundprocess" runat="server" autopostback="true"> <asp:listitem>usd</asp:listitem> <asp:listitem>cad</asp:listitem> <asp:listitem>gbp</asp:listitem> </asp:dropdownlist> </td> </tr> <tr> <td class="style13"> <asp:label id="lblesaccode" runat="server" text="esac code"></asp:label> </td> <td class="style5"> <asp:textbox id="tbesaccode" runat="server"></asp:textbox> </td> <td class="style4"> <asp:requiredfieldvalidator id="rfvesaccode" runat="server" controltovalidate="tbesaccode" errormessage="enter esac code" font-bold="true" forecolor="red">*</asp:requiredfieldvalidator> </td> <td class="style5"> <asp:label id="lblrefundablecommision" runat="server" text="refundable commission"></asp:label> </td> <td class="style11"> <asp:textbox id="tbrefundablecommision" runat="server"></asp:textbox> </td> <td> <asp:requiredfieldvalidator id="rfvrefundablecommission" runat="server" controltovalidate="tbrefundablecommision" errormessage="requiredfieldvalidator" font-bold="true" forecolor="red">*</asp:requiredfieldvalidator> </td> <td> <asp:dropdownlist id="ddlrefundablecommission" runat="server" autopostback="true"> <asp:listitem>usd</asp:listitem> <asp:listitem>cad</asp:listitem> <asp:listitem>gbp</asp:listitem> </asp:dropdownlist> </td> </tr> <tr> <td class="style13"> <asp:label id="lblwaivercode" runat="server" text="waiver code"></asp:label> </td> <td class="style5"> <asp:textbox id="tbwaivercode" runat="server"></asp:textbox> </td> <td class="style4"> <asp:requiredfieldvalidator id="rfvwaivercode" runat="server" controltovalidate="tbwaivercode" errormessage="enter waiver code" font-bold="true" forecolor="red">*</asp:requiredfieldvalidator> </td> <td class="style5"> <asp:label id="lblcouponrefunded" runat="server" text="coupon refunded"></asp:label> </td> <td class="style11"> <asp:textbox id="tbcouponrefund" runat="server"></asp:textbox> </td> <td> <asp:requiredfieldvalidator id="rfvcouponrefunded" runat="server" controltovalidate="tbcouponrefund" errormessage="enter coupon refund" font-bold="true" forecolor="red">*</asp:requiredfieldvalidator> </td> <td> </td> </tr> <tr> <td class="style13"> <asp:label id="label7" runat="server" text="remarks"></asp:label> </td> <td class="style5"> <asp:textbox id="tbremarks" runat="server" textmode="multiline"></asp:textbox> </td> <td class="style4"> <asp:requiredfieldvalidator id="rfvremarks" runat="server" controltovalidate="tbremarks" errormessage="enter remarks" font-bold="true" forecolor="red">*</asp:requiredfieldvalidator> </td> <td class="style5"> <asp:label id="lblrefundtype" runat="server" text="refund type"></asp:label> </td> <td class="style11"> <asp:dropdownlist id="ddlrefundtype" runat="server"> <asp:listitem>full</asp:listitem> <asp:listitem>partial</asp:listitem> </asp:dropdownlist> </td> <td> <asp:requiredfieldvalidator id="rfvrefundtype" runat="server" controltovalidate="ddlrefundtype" errormessage="select refund type" font-bold="true" forecolor="red">*</asp:requiredfieldvalidator> </td> <td> </td> </tr> <tr> <td class="style13" colspan="7"> <asp:button id="btnsubmit" runat="server" onclick="btnsubmit_click" text="submit"/> <asp:button id="btnreset" runat="server" onclick="btnreset_click" text="reset"/> </td> </tr> </table>
aspx.cs page code:
protected void btnsubmit_click(object sender, eventargs e) { sqlconnection con = new sqlconnection("data source=.;initial catalog=bart;integrated security=true"); con.open(); string portal = ddlportal.selectedvalue; string tid = tbtid.text; string pnr = tbpnr.text; string ticketnumber = tbticketnumber.text; string esaccode = tbesaccode.text; string waivercode = tbwaivercode.text; string remarks = tbremarks.text; string unusedticketamount = tbunusedticketamount.text; string unusedamount = ddlunusedamount.selectedvalue; string airlinepenality = tbairlinepenality.text; string airline = ddlairlinepenality.selectedvalue; string netrefundprocess = tbnetrefundprocess.text; string netrefund = ddlnetrefundprocess.selectedvalue; string refundablecommission = tbrefundablecommision.text; string refundable = ddlrefundablecommission.selectedvalue; string couponrefunded = tbcouponrefund.text; string refundtype = ddlrefundtype.selectedvalue; using (sqlcommand cmd = con.createcommand()) { cmd.commandtext = "insert form3(portal,tid,pnr,ticketnumber,esaccode,waivercode,remarks,unusedticketamount,ddlunusedamount, airlinepenality, ddlairlinepenality, netrefundprocess, ddlnetrefundprocess, refundablecommission, ddlrefundablecommission, couponrefunded,refundtype) values('" + portal + "','" + tid + "','" + pnr + "','" + ticketnumber + "', '" + esaccode + "', '" + waivercode + "', '" + remarks + "','" + unusedticketamount + "','" + unusedamount + "','" + airlinepenality + "','" + airline + "','" + netrefundprocess + "','" + netrefund + "','" + refundablecommission + "','" + refundable + "','" + couponrefunded + "','" + refundtype + "')"; cmd.parameters.addwithvalue("@portal", ddlportal.selectedindex); cmd.parameters.addwithvalue("@tid", tbtid.text.trim()); cmd.parameters.addwithvalue("@pnr", tbpnr.text.trim()); cmd.parameters.addwithvalue("@ticketnumber", tbticketnumber.text.trim()); cmd.parameters.addwithvalue("@esaccode", tbesaccode.text.trim()); cmd.parameters.addwithvalue("@waivercode", tbwaivercode.text.trim()); cmd.parameters.addwithvalue("@remarks", tbremarks.text.trim()); cmd.parameters.addwithvalue("@unusedticketamount", tbunusedticketamount.text.trim()); cmd.parameters.addwithvalue("@ddlunusedamount", ddlunusedamount.selectedindex); cmd.parameters.addwithvalue("@airlinepenality", tbairlinepenality.text.trim()); cmd.parameters.addwithvalue("@ddlairlinepenality", ddlairlinepenality.selectedindex); cmd.parameters.addwithvalue("@netrefundprocess", tbnetrefundprocess.text.trim()); cmd.parameters.addwithvalue("@ddlnetrefundprocess", ddlnetrefundprocess.selectedindex); cmd.parameters.addwithvalue("@refundablecommission", tbrefundablecommision.text.trim()); cmd.parameters.addwithvalue("@ddlrefundablecommission", ddlrefundablecommission.selectedindex); cmd.parameters.addwithvalue("@couponrefunded", tbcouponrefund.text.trim()); cmd.parameters.addwithvalue("@refundtype", ddlrefundtype.selectedindex); cmd.executenonquery(); } con.close(); tbtid.text = ""; tbpnr.text = ""; tbticketnumber.text = ""; tbesaccode.text = ""; tbwaivercode.text = ""; tbremarks.text = ""; tbremarks.text = ""; tbunusedticketamount.text = ""; tbairlinepenality.text = ""; tbnetrefundprocess.text = ""; tbrefundablecommision.text = ""; tbcouponrefund.text = ""; lblrefundtype.text = ""; tbtid.focus(); }
second report page::
<asp:gridview id="gridview1" runat="server" cellpadding="4" forecolor="#333333" gridlines="none" autogeneratecolumns="false" onrowcommand="gridview1_rowcommand1"> <columns> <asp:templatefield headertext="query"> <itemtemplate> <asp:linkbutton commandname="cmdbind" runat="server" text='<%#eval("id")%>' id="id" tooltip='<%#eval("id")%>'>linkbutton </asp:linkbutton> </itemtemplate> </asp:templatefield> <asp:boundfield datafield="portal" headertext="portal" itemstyle-horizontalalign="center"/> <asp:boundfield datafield="tid" headertext="tid" itemstyle-horizontalalign="center"/> <asp:boundfield datafield="pnr" headertext="pnr" itemstyle-horizontalalign="center"/> <asp:boundfield datafield="ticketnumber" headertext="ticket number" itemstyle-horizontalalign="center"/> <asp:boundfield datafield="esaccode" headertext="esaccode" itemstyle-horizontalalign="center"/> <asp:boundfield datafield="waivercode" headertext="waivercode" itemstyle-horizontalalign="center"/> <asp:boundfield datafield="remarks" headertext="remarks" itemstyle-horizontalalign="center"/> <asp:boundfield datafield="unusedticketamount" headertext="unusedticketamount" itemstyle-horizontalalign="center"/> <asp:boundfield datafield="ddlunusedamount" headertext="ddlunusedamoun" itemstyle-horizontalalign="center"/> <asp:boundfield datafield="airlinepenality" headertext="airlinepenality" itemstyle-horizontalalign="center"/> <asp:boundfield datafield="ddlairlinepenality" headertext="ddlairlinepenality" itemstyle-horizontalalign="center"/> <asp:boundfield datafield="netrefundprocess" headertext="netrefundprocess" itemstyle-horizontalalign="center"/> <asp:boundfield datafield="ddlnetrefundprocess" headertext="ddlnetrefundprocess" itemstyle-horizontalalign="center"/> <asp:boundfield datafield="refundablecommission" headertext="refundablecommission" itemstyle-horizontalalign="center"/> <asp:boundfield datafield="ddlrefundablecommission" headertext="ddlrefundablecommission" itemstyle-horizontalalign="center"/> <asp:boundfield datafield="couponrefunded" headertext="couponrefunded" itemstyle-horizontalalign="center"/> <asp:boundfield datafield="refundtype" headertext="refundtype" itemstyle-horizontalalign="center"/> </columns> <alternatingrowstyle backcolor="white" /> <editrowstyle backcolor="#2461bf" /> <footerstyle backcolor="#507cd1" font-bold="true" forecolor="white" /> <headerstyle backcolor="#507cd1" font-bold="true" forecolor="white" /> <pagerstyle backcolor="#2461bf" forecolor="white" horizontalalign="center" /> <rowstyle backcolor="#eff3fb" /> <selectedrowstyle backcolor="#d1ddf1" font-bold="true" forecolor="#333333" /> <sortedascendingcellstyle backcolor="#f5f7fb" /> <sortedascendingheaderstyle backcolor="#6d95e1" /> <sorteddescendingcellstyle backcolor="#e9ebef" /> <sorteddescendingheaderstyle backcolor="#4870be" /> </asp:gridview>
aspx.cs page of report:
protected void page_load(object sender, eventargs e) { try { if (!page.ispostback) { cmd = new sqlcommand("select * form3", con); da = new sqldataadapter(cmd); dt.clear(); con.open(); da.fill(dt); if (dt.rows.count > 0) { gridview1.datasource = dt; gridview1.databind(); } con.close(); } } catch (exception ex) { response.write(ex.tostring()); } } protected void gridview1_rowcommand1(object sender, gridviewcommandeventargs e) { if (e.commandname == "cmdbind") { linkbutton lb = (linkbutton)e.commandsource; response.redirect("form.aspx?id=" + lb.text + ""); } }
you need use state management
technique implement this. have used session
demonstrate.
on page have submit
button need create property
this:
public string buttontextvalue { { if (session["buttonvalue"] == null) session["buttonvalue"] = "submit"; return convert.tostring(session["buttonvalue"]); } set { session["buttonvalue"] = value; } }
on pageload
of same page need this:
protected void page_load(object sender, eventargs e) { if (!ispostback) { yourbutton.text = buttontextvalue; } }
and on second page need this:
protected void gridview1_rowcommand(object sender, gridviewcommandeventargs e) { if (e.commandname == "cmdbind") { linkbutton lb = (linkbutton)e.commandsource; session["buttonvalue"] = "update"; response.redirect("form.aspx?id=" + lb.text + ""); } }
Comments
Post a Comment