Radio Button, change, SQL querieshttp://forums.asp.net/t/1792478.aspx/1?Radio+Button+change+SQL+queriesThu, 19 Apr 2012 09:47:34 -040017924784930627http://forums.asp.net/p/1792478/4930627.aspx/1?Radio+Button+change+SQL+queriesRadio Button, change, SQL queries <p>Hi,</p> <p>On our&nbsp;search interface page&nbsp;there are 2 radio buttons.</p> <p>1. If Round-trip: Run Both SQL queries</p> <p>2. If One-way: Deactivate TextBox4 with Calendar Control and run only 1.SQL query</p> <p>Rest of button event left out for simplicity.</p> <p>Please help with code-behind for the radio button change event. Thanks!</p> <pre class="prettyprint">&lt;td&gt; &lt;asp:RadioButton ID=&quot;RadioButton1&quot; runat=&quot;server&quot; Text=&quot;Round-trip&quot; CssClass=&quot;text&quot; /&gt; &lt;/td&gt; &lt;td&gt; &amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;asp:RadioButton ID=&quot;RadioButton2&quot; runat=&quot;server&quot; Text=&quot;One-way&quot; CssClass=&quot;text&quot; /&gt; &lt;/td&gt;</pre> <pre class="prettyprint">&lt;td&gt; &lt;asp:TextBox ID="TextBox4" runat="server" CssClass="text_box"&gt;&lt;/asp:TextBox&gt; &lt;asp:CalendarExtender ID="TextBox4_CalendarExtender" runat="server" Enabled="True" Format="dd/MM/yyyy" TargetControlID="TextBox4"&gt; &lt;/asp:CalendarExtender&gt; &lt;/td&gt;</pre> <pre class="prettyprint">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(); }</pre> <p><br> <br> <br> </p> <p>&nbsp;</p> 2012-04-13T08:15:02-04:004930638http://forums.asp.net/p/1792478/4930638.aspx/1?Re+Radio+Button+change+SQL+queriesRe: Radio Button, change, SQL queries <pre class="prettyprint">hi try this</pre> <pre class="prettyprint">&lt;td&gt; &lt;asp:RadioButton ID="RadioButton1" runat="server" Text="Round-trip" AutoPostBack="true" oncheckedchanged="RadioButton1_CheckedChanged" CssClass="text" /&gt; &lt;/td&gt; &lt;td&gt; &amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;asp:RadioButton ID="RadioButton2" runat="server" Text="One-way" AutoPostBack="true" oncheckedchanged="RadioButton1_CheckedChanged" CssClass="text" /&gt; &lt;/td&gt;</pre> <p></p> <pre class="prettyprint"> protected void RadioButton1_CheckedChanged(object sender, EventArgs e) { RadioButton radio = sender as RadioButton; if (radio.Text == "One-way") { //logic here } else { //loic here } }</pre> <p><br> <br> </p> 2012-04-13T08:23:33-04:004930676http://forums.asp.net/p/1792478/4930676.aspx/1?Re+Radio+Button+change+SQL+queriesRe: Radio Button, change, SQL queries <p>in your button click....</p> <p>If(RadioButton1.Checked) { // do your 2 sql queries stuff here }</p> <p>If (RadioButton2.Checked)&nbsp;{ // do your textbox clearing stuff here }</p> <p>....and rest code follows here...</p> <p>Thanks,</p> 2012-04-13T08:55:12-04:004940683http://forums.asp.net/p/1792478/4940683.aspx/1?Re+Radio+Button+change+SQL+queriesRe: Radio Button, change, SQL queries <pre class="prettyprint">Hi, <pre></pre> protected void RadioButton1_CheckedChanged(object sender, EventArgs e) { RadioButton radio = sender as RadioButton; if (radio.Text == &quot;One-way&quot;) { //logic here //does the db connection string and query go here? } else { //loic here } }</pre> <p>Can you provide an example? Thanks!</p> 2012-04-19T09:47:34-04:00