Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi i am creating an application in which i have home page where i have a drop-down list. On selecting value from the list a form will appear accordingly, now when i press on submit button entered data in form stored in my database On my second page i have a drop-down list with same value, from and to date text-box to select dates and a grid-view. now what i want is when i select drop-down list and select dates in the text-box i get the data in my grid for the particular dates and value selected from drop-down list in grid.
 
Code:
<form id="form1" runat="server">
      <div id="FirstForm" style="margin-left: 80px">
      <asp:TextBox ID="tbid" runat="server" Enabled="false"
       Visible="false" Width="137px"></asp:TextBox>
       &nbsp;&nbsp;&nbsp;
   <br />
   <asp:ValidationSummary ID="vdm" runat="server" ForeColor="Red" />
 <table class="style1">
       <tr>
           <td class="style13">
   <asp:Label ID="lblPortal" runat="server" Text="Select Portal"></asp:Label>
           </td>
           <td class="style5">
   <asp:DropDownList ID="ddlPortal" runat="server" AutoPostBack="True"
       onselectedindexchanged="ddlPortal_SelectedIndexChanged">
       <asp:ListItem>TRAVELONG</asp:ListItem>
       <asp:ListItem>ONETRAVEL</asp:ListItem>
       <asp:ListItem>.UK-BSP</asp:ListItem>
       <asp:ListItem>.CA-YYZ</asp:ListItem>
       <asp:ListItem>.CA-YVR</asp:ListItem>
       <asp:ListItem>Partial MCO Refund</asp:ListItem>
   </asp:DropDownList>
           </td>
           <td class="style4">
               &nbsp;</td>
           <td class="style5">
               &nbsp;</td>
           <td class="style11">
               &nbsp;</td>
           <td>
               &nbsp;</td>
           <td>
               &nbsp;</td>
       </tr>
       <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>
               &nbsp;</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>
               &nbsp;</td>
       </tr>
       <tr>
           <td class="style13" colspan="7">
               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
               &nbsp;<asp:Button ID="btnSubmit" runat="server" onclick="btnSubmit_Click"
                   Text="Submit"/>
           &nbsp;&nbsp;&nbsp;&nbsp;
               <asp:Button ID="btnReset" runat="server" onclick="btnReset_Click" Text="Reset" ValidationGroup="xyz"/>
           &nbsp;&nbsp;&nbsp;&nbsp;
               </td>
       </tr>
   </table>
 
aspx.cs code for first page
 
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=Bart;Integrated Security=True");
SqlCommand sqlcmd;
SqlDataAdapter da;
DataTable dt = new DataTable();
 
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["portal"] != null)
{
ddlPortal.SelectedIndex = ddlPortal.Items.IndexOf(ddlPortal.Items.FindByValue(Convert.ToString(Session["portal"])));
}
string ID = Request.QueryString["ID"];
if (ID == "")
{
Response.Write("Invalid Selection");
return;
}
sqlcmd = new SqlCommand("Select * from Form3 where ID='" + ID + "'", con);
con.Open();
da = new SqlDataAdapter(sqlcmd);
dt.Clear();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
tbid.Text = ID;
ddlPortal.SelectedValue = dt.Rows[0][1].ToString();
tbTid.Text = dt.Rows[0][2].ToString();
tbPNR.Text = dt.Rows[0][3].ToString();
tbTicketNumber.Text = dt.Rows[0][4].ToString();
tbESACCode.Text = dt.Rows[0][5].ToString();
tbWaiverCode.Text = dt.Rows[0][6].ToString();
tbRemarks.Text = dt.Rows[0][7].ToString();
tbUnusedTicketAmount.Text = dt.Rows[0][8].ToString();
ddlUnusedAmount.SelectedValue = dt.Rows[0][9].ToString();
tbAirlinePenality.Text = dt.Rows[0][10].ToString();
ddlAirlinePenality.SelectedValue = dt.Rows[0][11].ToString();
tbNetRefundProcess.Text = dt.Rows[0][12].ToString();
ddlNetRefundProcess.SelectedValue = dt.Rows[0][13].ToString();
tbRefundableCommision.Text = dt.Rows[0][14].ToString();
ddlRefundableCommission.SelectedValue = dt.Rows[0][15].ToString();
tbCouponRefund.Text = dt.Rows[0][16].ToString();
ddlRefundType.SelectedValue = dt.Rows[0][17].ToString();
}
con.Close();
}
}
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();
}
protected void ddlPortal_SelectedIndexChanged(object sender, EventArgs e)
{
Session["portal"] = ddlPortal.SelectedValue;
 
if (ddlPortal.SelectedValue == "TRAVELONG")
{
ddlUnusedAmount.SelectedItem.Text = "USD";
ddlUnusedAmount.Enabled = true;
ddlAirlinePenality.SelectedItem.Text = "USD";
ddlAirlinePenality.Enabled = true;
ddlNetRefundProcess.SelectedItem.Text = "USD";
ddlAirlinePenality.Enabled = true;
ddlRefundableCommission.SelectedItem.Text = "USD";
ddlRefundableCommission.Enabled = true;
}
else if (ddlPortal.SelectedValue == "ONETRAVEL")
{
ddlUnusedAmount.SelectedItem.Text = "USD";
ddlUnusedAmount.Enabled = true;
ddlAirlinePenality.SelectedItem.Text = "USD";
ddlAirlinePenality.Enabled = true;
ddlNetRefundProcess.SelectedItem.Text = "USD";
ddlAirlinePenality.Enabled = true;
ddlRefundableCommission.SelectedItem.Text = "USD";
ddlRefundableCommission.Enabled = true;
}
else if (ddlPortal.SelectedValue == ".UK-BSP")
{
ddlUnusedAmount.SelectedItem.Text = "GBP";
ddlUnusedAmount.Enabled = true;
ddlAirlinePenality.SelectedItem.Text = "GBP";
ddlAirlinePenality.Enabled = true;
ddlNetRefundProcess.SelectedItem.Text = "GBP";
ddlAirlinePenality.Enabled = true;
ddlRefundableCommission.SelectedItem.Text = "GBP";
ddlRefundableCommission.Enabled = true;
}
else if (ddlPortal.SelectedValue == ".CA-YYZ")
{
ddlUnusedAmount.SelectedItem.Text = "CAN";
ddlUnusedAmount.Enabled = true;
ddlAirlinePenality.SelectedItem.Text = "CAN";
ddlAirlinePenality.Enabled = true;
ddlNetRefundProcess.SelectedItem.Text = "CAN";
ddlAirlinePenality.Enabled = true;
ddlRefundableCommission.SelectedItem.Text = "CAN";
ddlRefundableCommission.Enabled = true;
}
else if (ddlPortal.SelectedValue == ".CA-YVR")
{
ddlUnusedAmount.SelectedItem.Text = "CAN";
ddlUnusedAmount.Enabled = true;
ddlAirlinePenality.SelectedItem.Text = "CAN";
ddlAirlinePenality.Enabled = true;
ddlNetRefundProcess.SelectedItem.Text = "CAN";
ddlAirlinePenality.Enabled = true;
ddlRefundableCommission.SelectedItem.Text = "CAN";
ddlRefundableCommission.Enabled = true;
}
}
protected void btnReset_Click(object sender, EventArgs e)
{
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();
}
Posted 19-Mar-13 5:18am
Edited 19-Mar-13 5:31am
v5
Comments
ThePhantomUpvoter at 19-Mar-13 10:20am
   
Thanks for what? You have not asked a question nor have you described any kind of a problem.
Member 9671810 at 19-Mar-13 13:47pm
   
can you tell what is the real matter?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 515
1 Maciej Los 340
2 Richard MacCutchan 265
3 BillWoodruff 225
4 Mathew Soji 155
0 OriginalGriff 8,804
1 Sergey Alexandrovich Kryukov 7,457
2 DamithSL 5,689
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web04 | 2.8.1411028.1 | Last Updated 19 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100