1

我在 asp.net (c#) 中使用表单来获取一些数据。在表单中,我有一些单选按钮列表。当已经存在寄存器时,我如何将数据发送到页面。我问数据库,如果有值,选择radiobuttonlist

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

问题是当我再次发送数据时,只需要更新,但数据不会改变,与我从数据库中恢复的相同。

4

1 回答 1

0

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.

于 2013-07-10T19:06:40.770 回答