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 8289129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:26:16+00:00 2026-06-08T12:26:16+00:00

i have web application in which i used gridview. In gridview i used radiobutton

  • 0

i have web application in which i used gridview. In gridview i used radiobutton list this radiobutton list has two item Yes and No.i want to select one item from these two depend on value i get from dataset at the time binding.suppose my column name is is_selected and it returns True then in radiobutton list Yes should be checked.
This is code i have tried myself but no success,

 <asp:TemplateField HeaderText="Ready To Join?" ItemStyle-HorizontalAlign="Center">
                        <ItemTemplate>


                   <asp:RadioButtonList ID="rbd_join" AutoPostBack="true" runat="server" 
                            RepeatDirection="Horizontal" BorderStyle="None" BorderWidth="0px" BorderColor="Transparent"
                            onselectedindexchanged="rbd_join_SelectedIndexChanged" 
                            DataValueField="is_selected">
                        <asp:ListItem Text="Yes" Value="1" ></asp:ListItem>
                        <asp:ListItem Text="No" Value="0"></asp:ListItem>
                        </asp:RadioButtonList>
                        </ItemTemplate>

<ItemStyle HorizontalAlign="Center"></ItemStyle>
                    </asp:TemplateField>

After Edit

Addition

.cs file
on button click event this is code:

Dataset  ds=new Dataset();
ds=bindgrid();
if(ds.table[0].rows.count>0)
{
    grd_view.Datasource=ds.tables[0];
    grd_view.Databind();
}
public Dataset bindgrid()
{
    SqlParameter stud_ID = new SqlParameter("@student_id", SqlDbType.Int);
                stud_ID.Value = 1;
                SqlCommand cmdSql = new SqlCommand();
                cmdSql.CommandType = CommandType.StoredProcedure;
                cmdSql.CommandText = "usp_select_candidate_inplacement_byAdmin";
                cmdSql.Parameters.Add(stud_ID);
                DataSet ds = new DataSet();
                DataClass dl = new DataClass();
                ds = dl.dsSelect(cmdSql);
                return ds;
}

and this is event i added

protected void grd_view_RowDataBound(object sender, GridViewRowEventArgs e)
{
  if (e.Row.RowType == DataControlRowType.DataRow)
            {
                var radioList = e.Row.FindControl("rbd_join") as RadioButtonList;
                var myobject = e.Row.DataItem as DataRow;
                bool is_sel = bool.Parse(myobject ["is_selected"].ToString());

                radioList.SelectedValue = is_sel ? "1" : "0";

            }
}
  • 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-06-08T12:26:18+00:00Added an answer on June 8, 2026 at 12:26 pm

    You need to use the RowDataBound event:

    ASPX

    <asp:GridView ..... OnRowDataBound="gv_RowDataBound"
    

    Code behind

    protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            var radioList = e.Row.FindControl("rbd_join") as RadioButtonList;
    
            // this will be the object that you are binding to the grid
            var myObject = e.Row.DataItem as DataRowView;
            bool isSelected = bool.Parse(myObject["is_selected"].ToString());
    
            radioList.SelectedValue = isSelected ? "1" : "0";
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application which is used by lots of non-technical users. I
I have a web application which uses membership and profiles. I successfully used the
I have a web application which uses URLs that look like this: http://library.example.com/Register.aspx?query=academic&key=586c70bb-5683-419c-aae9-e596af9ab66a (The
I have build a web application which shows the list of customers using datalist
In a nutshell, I have a web application which used to be able to
I have a working web application which already has a login and registration system.
I have a fairly standard ASP.Net web application which is used via mobile safari
I have used threading in my web application which I have mentioned below: var
I have web application, in which I have used Spring framework. For the concurrent
I have a web application in which I have used jQuery validation engine for

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.