Click here to Skip to main content
15,884,022 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a small web application but when i retrieve data to edit ,i can retrieve every cell to there textbox but i can't get radio button value

C#
SqlDataReader dr;

dr = comm.ExecuteReader();
if (dr.HasRows == true)
{
    dr.Read();
    RegionNameTextBox.Text = dr["RegionNameEn"].ToString();
    StatusRadioButtonList.Text = dr["RegionStatus"].ToString();
    dr.Close();
    comm.Parameters.Clear();
}
Posted
Updated 26-Nov-17 23:13pm
Comments
prashant patil 4987 11-Sep-12 2:04am    
first check your radio value bind to radio button or not.

Looks like you are trying to assign a Radio Button checked or not-checked.

C#
//To set the text of the Radiobutton
StatusRadioButtonList.Text = "Selected value";

//Tot set checked or not
StatusRadioButtonList.Checked = true;

//If you are trying to check and set more than 1 Radio button
//All the radio button should of same group
if (rdoStatusRadioButtonListA.Text.ToString().Equals("One"))
        {
            rdoStatusRadioButtonListA.Checked = true;
        }
else  {
            rdoStatusRadioButtonListA.Checked = false;
            rdoStatusRadioButtonListB.Checked = true;
     }


Let me know if this answer doesn't solve your problem. I will provide in much detail.
 
Share this answer
 
Comments
M.Saied 11-Sep-12 2:42am    
i got this error (RadioButtonList' does not contain a definition for 'Checked' )
i have one radio button list with two option (Enable , Disable) and i used this
StatusRadioButtonList.SelectedIndex =Convert.ToInt32(dr["RegionStatus"]) and works fine but its reflect value if it enable i get it in radio button disable and vice but in database its ok
If you retrieving the Active or Inactive value from database you can use following code,
C#
if(dr["RegionStatus"].ToString()=="Active")
{
   StatusRadioButtonList.Items[0].Selected=true;
   StatusRadioButtonList.Items[1].Selected=false;
}
else if(dr["RegionStatus"].ToString()=="Inactive")
{
   StatusRadioButtonList.Items[0].Selected=false;
   StatusRadioButtonList.Items[1].Selected=true;
}
 
Share this answer
 
Comments
M.Saied 11-Sep-12 3:06am    
thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900