Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 19, 2012 09:47 AM by Peter2010
Member
10 Points
38 Posts
Apr 13, 2012 08:15 AM|LINK
Hi,
On our search interface page there are 2 radio buttons.
1. If Round-trip: Run Both SQL queries
2. If One-way: Deactivate TextBox4 with Calendar Control and run only 1.SQL query
Rest of button event left out for simplicity.
Please help with code-behind for the radio button change event. Thanks!
<td> <asp:RadioButton ID="RadioButton1" runat="server" Text="Round-trip" CssClass="text" /> </td> <td> </td> </tr> <tr> <td> <asp:RadioButton ID="RadioButton2" runat="server" Text="One-way" CssClass="text" /> </td>
<td> <asp:TextBox ID="TextBox4" runat="server" CssClass="text_box"></asp:TextBox> <asp:CalendarExtender ID="TextBox4_CalendarExtender" runat="server" Enabled="True" Format="dd/MM/yyyy" TargetControlID="TextBox4"> </asp:CalendarExtender> </td>
protected void Button1_Click(object sender, EventArgs e) { string pleaving = DropDownList3.SelectedItem.Text; string parriving = DropDownList4.SelectedItem.Text; string pclass = DropDownList2.SelectedItem.Text; string poutbound = TextBox3.Text; string pinbound = TextBox4.Text; //System.Threading.Thread.Sleep(5000); GridView1.DataSource = Outbound(pleaving, parriving, pclass, poutbound); GridView1.DataBind(); GridView2.DataSource = Inbound(parriving, pleaving, pclass, pinbound); GridView2.DataBind(); }
Participant
1839 Points
532 Posts
Apr 13, 2012 08:23 AM|LINK
hi try this
<td> <asp:RadioButton ID="RadioButton1" runat="server" Text="Round-trip" AutoPostBack="true" oncheckedchanged="RadioButton1_CheckedChanged" CssClass="text" /> </td> <td> </td> </tr> <tr> <td> <asp:RadioButton ID="RadioButton2" runat="server" Text="One-way" AutoPostBack="true" oncheckedchanged="RadioButton1_CheckedChanged" CssClass="text" /> </td>
protected void RadioButton1_CheckedChanged(object sender, EventArgs e) { RadioButton radio = sender as RadioButton; if (radio.Text == "One-way") { //logic here } else { //loic here } }
All-Star
95463 Points
14106 Posts
Apr 13, 2012 08:55 AM|LINK
in your button click....
If(RadioButton1.Checked) { // do your 2 sql queries stuff here }
If (RadioButton2.Checked) { // do your textbox clearing stuff here }
....and rest code follows here...
Thanks,
Apr 19, 2012 09:47 AM|LINK
Hi, protected void RadioButton1_CheckedChanged(object sender, EventArgs e) { RadioButton radio = sender as RadioButton; if (radio.Text == "One-way") { //logic here //does the db connection string and query go here? } else { //loic here } }
Can you provide an example? Thanks!
Peter2010
Member
10 Points
38 Posts
Radio Button, change, SQL queries
Apr 13, 2012 08:15 AM|LINK
Hi,
On our search interface page there are 2 radio buttons.
1. If Round-trip: Run Both SQL queries
2. If One-way: Deactivate TextBox4 with Calendar Control and run only 1.SQL query
Rest of button event left out for simplicity.
Please help with code-behind for the radio button change event. Thanks!
<td> <asp:RadioButton ID="RadioButton1" runat="server" Text="Round-trip" CssClass="text" /> </td> <td> </td> </tr> <tr> <td> <asp:RadioButton ID="RadioButton2" runat="server" Text="One-way" CssClass="text" /> </td><td> <asp:TextBox ID="TextBox4" runat="server" CssClass="text_box"></asp:TextBox> <asp:CalendarExtender ID="TextBox4_CalendarExtender" runat="server" Enabled="True" Format="dd/MM/yyyy" TargetControlID="TextBox4"> </asp:CalendarExtender> </td>protected void Button1_Click(object sender, EventArgs e) { string pleaving = DropDownList3.SelectedItem.Text; string parriving = DropDownList4.SelectedItem.Text; string pclass = DropDownList2.SelectedItem.Text; string poutbound = TextBox3.Text; string pinbound = TextBox4.Text; //System.Threading.Thread.Sleep(5000); GridView1.DataSource = Outbound(pleaving, parriving, pclass, poutbound); GridView1.DataBind(); GridView2.DataSource = Inbound(parriving, pleaving, pclass, pinbound); GridView2.DataBind(); }shivalthakur
Participant
1839 Points
532 Posts
Re: Radio Button, change, SQL queries
Apr 13, 2012 08:23 AM|LINK
<td> <asp:RadioButton ID="RadioButton1" runat="server" Text="Round-trip" AutoPostBack="true" oncheckedchanged="RadioButton1_CheckedChanged" CssClass="text" /> </td> <td> </td> </tr> <tr> <td> <asp:RadioButton ID="RadioButton2" runat="server" Text="One-way" AutoPostBack="true" oncheckedchanged="RadioButton1_CheckedChanged" CssClass="text" /> </td>protected void RadioButton1_CheckedChanged(object sender, EventArgs e) { RadioButton radio = sender as RadioButton; if (radio.Text == "One-way") { //logic here } else { //loic here } }Response.Write("Success");
Best Of Luck
Shival Thakur
ramiramilu
All-Star
95463 Points
14106 Posts
Re: Radio Button, change, SQL queries
Apr 13, 2012 08:55 AM|LINK
in your button click....
If(RadioButton1.Checked) { // do your 2 sql queries stuff here }
If (RadioButton2.Checked) { // do your textbox clearing stuff here }
....and rest code follows here...
Thanks,
JumpStart
Peter2010
Member
10 Points
38 Posts
Re: Radio Button, change, SQL queries
Apr 19, 2012 09:47 AM|LINK
Hi, protected void RadioButton1_CheckedChanged(object sender, EventArgs e) { RadioButton radio = sender as RadioButton; if (radio.Text == "One-way") { //logic here //does the db connection string and query go here? } else { //loic here } }Can you provide an example? Thanks!