ToBe

ToBe

  • NA
  • 164
  • 94.1k

repeation when retrieve radiobuttonlist value for editing

May 15 2013 2:58 AM
Hi 

I have  a problem when retrieve  the value of my radio button list from database for editing purpose it will retrieve all of the inserted values and select the right one but it will give more than 20 radio button in the form   while i want the orignal radiobuttonlist with the one selected before which is in total 3 radio button .

this is my code :

 SqlDataAdapter da = new SqlDataAdapter("SELECT dbo.tblType.Type_ID, dbo.tblType.Type_Name FROM dbo.tblReg_Details INNER JOIN dbo.tblType ON dbo.tblReg_Details.Type_ID = dbo.tblType.Type_ID",con);

            DataSet ds_type = new DataSet();

            da.Fill(ds_type, "tblType");

            rdblType.DataTextField = "Type_Name"; 

            rdblType.DataValueField = "Type_ID"; 

            rdblType.DataSource = ds_type.Tables["tblType"];

            rdblType.DataBind();


 foreach (ListItem litem2 in rdblType.Items)
                {
                    if (litem2.Text == DS.Tables[0].Rows[0].ItemArray[6].ToString())
                    {
                        litem2.Selected = true;
                    }

                }

kindly help me how to fix this error 



Answers (10)