Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3759334
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T10:18:02+00:00 2026-05-19T10:18:02+00:00

i have a radio button list that on selecting, queries a table and displays

  • 0

i have a radio button list that on selecting, queries a table and displays data in a textarea. now i’m trying to enhance my code so that the value of the radio button is displayed within the URL. that way i can send users links to content displayed by the radio selection (i.e. articles).

So far i’ve been able to place the “Article_PK” within the url successfully when the user makes a selection. now i’m just stuck on how to get my databind working again. so basically, i need to read in the value of the “Article_PK” in the url to display the data within the textarea. need someone with some mad coding skills to save the day!

code behind ——–

public partial class frm_Articles : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {


        if (Page.IsPostBack == false)
        {


            RadioButtonList1.SelectedIndex = 0;
            RadioButtonList1.DataBind();

        }

        else
        {

            string strRedirect;

            strRedirect = "frm_Articles.aspx?Article_PK=" + RadioButtonList1.SelectedValue.ToString();

            Response.Redirect(strRedirect);


        }
    }  



    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)
     {

     }


    }



}

—– aspx

  <tr valign="top">
        <td  width="75%">

        <!-- Body -->
            <asp:DetailsView ID="DetailsView3" runat="server" AutoGenerateRows="False" DataSourceID="SqlDataSource2" Height="100%" Width="100%" GridLines="None">
                <Fields>


                    <asp:TemplateField HeaderText="ArticleText" ShowHeader="False" SortExpression="ArticleText">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ArticleText") %>'></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="*"></asp:RequiredFieldValidator>
                        </EditItemTemplate>
                        <InsertItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ArticleText") %>'></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="*"></asp:RequiredFieldValidator>
                        </InsertItemTemplate>
                        <ItemTemplate>

                <%# Eval("ArticleText") %>


                        </ItemTemplate>
                    </asp:TemplateField>
                </Fields>
            </asp:DetailsView>
            <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:CSFConnectionString %>" SelectCommand="SELECT [ArticleText], [Title] FROM [TEST_Article] WHERE ([Article_PK] = @Article_PK)" onselecting="SqlDataSource2_Selecting">
                <SelectParameters>
                    <asp:ControlParameter ControlID="RadioButtonList1" DefaultValue="1" Name="Article_PK" PropertyName="SelectedValue" Type="Int32" ConvertEmptyStringToNull="True" />
                </SelectParameters>
            </asp:SqlDataSource>
            </td>
            <td  width="25%" align="left" valign="top">
                                                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TESTConnectionString %>" SelectCommand="SELECT Article_PK, ArticleText, Score, Title, Url_FK FROM TEST_Article WHERE (Url_FK = @URL_FK)" onselecting="SqlDataSource1_Selecting">
                                                    <SelectParameters>
                                                        <asp:Parameter DefaultValue="0" Name="Url_FK" Type="Int32" />
                                                    </SelectParameters>
                                                </asp:SqlDataSource>
                                                <h2>Articles</h2>
                                                <h2>Select an article below:</h2>
                                                <asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="Title" DataValueField="Article_PK">
                                                </asp:RadioButtonList>
                                                <br />

                                            </td></tr>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T10:18:02+00:00Added an answer on May 19, 2026 at 10:18 am

    If you didn’t build anything in your PageLoad event to handle the query string, then nothing will happen when the controls does a postback.

    Inside your pageLoad event you want something like:

    if(IsPostBack)
    {
        if(Request.QueryString["URL_PK"] != null)
        {
        int url_pk;
        if(int.TryParse(Request.QueryString["URL_PK"].ToString(), out url_pk)
        {
             //do whatever you need to do with url pk here
        }
    }
    

    Set your radio buttons to have autopostback="true" and you should get the desired effect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make radio buttons that when you have them active, it displays
I am trying to create a single-choice (e.g., radio button) list of items that
I have a page with radio buttons and a textarea that populates data dynamically
I have a radio button list that has buttons like this: http://imageshack.us/f/545/capture1jtr.png/ However, I
I have a Radio Button List that lists different business categories. The last option
I have radio button list in a gridview that needs to be bound to
I have a radio button list and some of the labels are quite long
I have a radio button list control on my ascx page and have a
i have a asp:radio button with two list items asp:RadioButtonList id=Myradio asp:listitem1 value=li1 asp:listitem2
I have MVC3 web application where we need to populate radio button list with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.