Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello

In my applcation i having a problem. I am retrieving user payment from database and according to that i want to check the cash cheque radio button checked.If user has done payment through cash then when i am retrieving user information from database the i want to show cash radio button checked.How can i do this.

thanks in advance
Posted
Comments
Dholakiya Ankit 18-Jul-13 8:11am    
what is the value stoered in your datbase and put code of your radio buttonlist
[no name] 18-Jul-13 8:12am    
I would imagine that you would do this the same exact way that you have already been told.
maneavnash 18-Jul-13 10:22am    
not clear........ please provider some code.......
sruthi liju 20-Jul-13 1:02am    
bqc.Idno = Session["idno"].ToString();
dr = bqc.question_comp_fill();

if (dr.Read())
{

//RadioButtonList1.SelectedItem.Selected= dr["com1"].ToString();
//RadioButtonList1.Items.FindByValue("com1").Selected = true;
//RadioButtonList2.Items.FindByText("com2").Selected = true;
//RadioButtonList1.SelectedItem.Text = dr["com1"].ToString();
//RadioButtonList2.SelectedItem.Text = dr["com2"].ToString();
string a = dr["com1"].ToString();
if (e.Row.Cells[1].Text.ToString() == "Yes")
{
chk.Checked = true;
}

RadioButtonList1.SelectedItem.Text = a;
Label1.Visible = true;
Label1.Text = Convert.ToString(dr["total"].ToString());
}
dr.Close();

this is the coding.i fetch from db yes or no as result.if yes the radiobutton corresponding to yes should be checked.

1 solution

If you are using Gridview, you can do this by implementing your code in
C#
GridView1_RowDataBound(...)
function

find your control here:
C#
CheckBox chk = (CheckBox)e.Row.Cells[0].FindControl("chk1");


Put the checkbox property checked true based on your condition:
C#
if (e.Row.Cells[1].Text.ToString() == "Yes")
{
    chk.Checked = true;
}
 
Share this answer
 

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