Click here to Skip to main content
15,917,642 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
public void LoadData()
    {
        SqlDataAdapter da = new SqlDataAdapter("Select Quantity from Client_StandardPostcardRequest where Edition_Id=" + Session["Edition_ID"].ToString() + " and Exhibitor_ID=" + Session["Exhibitor_ID"].ToString() + "", con);
        DataSet ds = new DataSet();
        da.Fill(ds);
        if (ds.Tables[0].Rows.Count > 0)
        {
            int i = (int)ds.Tables[0].Rows[0]["Quantity"];
            rblQuantity.SelectedItem.Text = i.ToString();
        }
    }


What I have tried:

I have tried the above code
I have inserted value of radio button list into database on button submit but when i want to retrieve value from database to the asp page value is also fetching but the particular radio button does not get checked.
Please help me in solving this issue
Posted
Updated 2-Nov-17 2:32am

1 solution

try
string value = ds.Tables[0].Rows[0]["Quantity"].ToString();
           ListItem targetItem = rblQuantity.Items.FindByValue(value);
           if (targetItem != null)
               targetItem.Selected = true;

use ListItemCollection.FindByValue Method [^] to find the radiobutton based on value
use ListItemCollection.FindByText Method [^] to find the radio button based on text
 
Share this answer
 
Comments
Member 13041059 2-Nov-17 9:14am    
This code worked for me
Karthik_Mahalingam 2-Nov-17 9:17am    
good

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