简体   繁体   中英

RadioButtonList selected value with database

I use a form in asp.net (c#) to get some data. In the form i have some radiobuttonlists. How can i send to a page the data when already exists a register. I ask to the database, if there is a value, radiobuttonlist is selected

RadioButtonList1.Items.FindByValue(uno.ToString()).Selected = true;

The problem is when i send the data again, just need to update, but the data don't change, are the same that i recovered from the db.

I'm not 100 % sure on what you are asking, so i'm going to summarize the question I think you are asking and give you the answer. You are asking how to grammatically select a radio button if you only know the value of the button.

radioButtonList1.Items.FindByText("Your Text").Selected = true;

radioButtonList1.Items.FindByValue("Your Text").Selected = true;

This will depend if you are searching for the "Value" field or the "Text" Field. If this is not working then the Value in the radio button and the value in your database are not matching. Try printing them both off on a screen to see if they are different.

Also Remember that the value and the text are two different properties in the radio button list.

The other question that I think you might be asking is if the page is not being updated at all, in which case did you enable AutoPostBack on the control you are using to implement these changes?

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM