Click here to Skip to main content
16,013,581 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have two radio buttons paid , not paid when search this two buttons are blank but i have saved details in database plz give me a solution ?

What I have tried:

i have two radio buttons paid , not paid when search this two buttons are blank but i have saved details in database plz give me a solution ?
Posted
Updated 7-Aug-16 23:11pm
Comments
Sampath_G 8-Aug-16 3:23am    
Explain the scenario in a detailed way. That could be helpful to get better solution.

As per your question i think, You are creating something which has paid and not paid values. After saving,while retrieving you are not able to project the value in the radio button.
Did you bind the retrieved data to the Radio Button properly? How did you bind that?
Richard MacCutchan 8-Aug-16 3:33am    
A solution to what? We have no idea what your code is doing or why it does not work.
[no name] 8-Aug-16 3:41am    
Paid/Not Paid (true/false) implies more a Checkbox and not two radio buttons
Karthik_Mahalingam 8-Aug-16 4:52am    
do you need to validate ?
BillWoodruff 8-Aug-16 5:48am    
First of all, use a CheckBox. Second, clarify your question: is the problem happening on the DB side or on the UI side. Is valid data being fetched from the DB ?

1 solution

Firstly store you "paid or not paid" value as bit in sql server.

when u retrieve that value, use as :


C#
SqlConnection con = new SqlConnection("You connection string");
SqlDataAdapter da = new SqlDataAdapter("Your select query", con);
DataTable dt = new DataTable();
da.Fill(dt);
for (int i = 0; i < dt.Rows.Count; i++)
{
    bool paid = Convert.ToBoolean(dt.Rows[i]["paid"]);

    rdoPaid.Checked = paid;
    rdoNotPaid.Checked = !rdoPaid.Checked;
}
 
Share this answer
 
Comments
BillWoodruff 8-Aug-16 5:47am    
If two RadioButtons are in the same "container" setting one of them to checked will mean the other(s) are automatically unchecked. That is the "function" of what RadioButtons are.

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