Note that there are some explanatory texts on larger screens.

plurals
  1. POlinking to a radiobutton value, data is not binding, asp.net c#
    text
    copied!<p>hi i need to modify my code a little bit. i have a page with a radio button list and a textarea. the textarea is populated when a users makes a radio button selection. </p> <p>also, when a user makes a radio button selection the url will hold an extention in the url to show which selection index number they have selection. (i.e. ?selected=0)</p> <p><a href="http://test.com/frm_Articles.aspx?selected=0" rel="nofollow">http://test.com/frm_Articles.aspx?selected=0</a> http://test.com/frm_Articles.aspx?selected=1 <a href="http://test.com/frm_Articles.aspx?selected=2" rel="nofollow">http://test.com/frm_Articles.aspx?selected=2</a></p> <p>that way they can copy the url and reference it in other websites as a link. or place it in their favorites. </p> <p><strong>the problem is,</strong> if you grab the url and open a new browser, the page does not pass the value and databind accordingly. no radio buttons or content appear on the page. must be the postback logic i think???</p> <p>what's working:</p> <ol> <li>when i launch the website the radio buttons appear and index 0 is set </li> <li>when i select radio buttons the correct data displays and urls linking to radio button values display in browser (i.e. <a href="http://test.com/test.aspx?selected=2" rel="nofollow">http://test.com/test.aspx?selected=2</a>)</li> <li>if i cut and paste pointer urls within the same browser then correct data is rendered</li> </ol> <p>what doesn't work (everything that deal with an false PostBack):</p> <p>1.when i launch website no data within the textarea apprears even though the radio button is set to 0 index and is visiable. 2. if i cut and paste pointer url into a new browser, text area and radio buttons do not display. </p> <pre><code> protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false) { int selected; if (Request.QueryString["selected"] != null) { if (int.TryParse(Request.QueryString["selected"], out selected)) { RadioButtonList1.SelectedIndex = selected; RadioButtonList1.DataBind(); } } else { int firstart = 0; RadioButtonList1.SelectedIndex = firstart; RadioButtonList1.DataBind(); } } } protected void SqlDataSource2_Selecting(object sender, SqlDataSourceSelectingEventArgs e) { // } protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e) { try{ e.Command.Parameters["@URL_FK"].Value = Session["URL_PK"]; } catch (Exception ex) { } } protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e) { string strRedirect; strRedirect = "test.aspx?selected=" + RadioButtonList1.SelectedIndex; Response.Redirect(strRedirect); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload