伙计们,我有两页在第一页我有我的表单,第二页是报告页面,我的表单值存储在网格中。我现在在我的表单页面上有提交按钮,当我点击编辑链接时,我将重定向到我的表单页面,我可以在其中进行更改和更新详细信息。现在我想要的是当我单击编辑链接并移动到我的表单页面以编辑我的提交按钮更改为更新按钮时我该怎么做...
这是我的第一页代码:
选择 TRAVELONG ONETRAVEL .UK-BSP .CA-YYZ .CA-YVR 部分 MCO 退款
<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 页面代码:
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 into 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();
}
第二个报告页::
<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 报告页面:
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!Page.IsPostBack)
{
cmd = new SqlCommand("select * from 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 + "");
}
}