Доступ к значению динамично созданных средств управления c# asp.net

Необходимо записать исполняемые процессы как 32-разрядные процессы (по сравнению с Любым ЦП или x64) так, чтобы они были загружены WoW32 для Vista. Это загрузит их в 32-разрядном режиме эмуляции, и у Вас не будет проблемы точки входа. Можно оставить Вас библиотеками в режиме AnyCPU, но Ваши исполняемые файлы должны быть скомпилированы как x86.

6
задан Andrew 28 September 2009 в 15:14
поделиться

2 ответа

Hi it sounds to me like you are bit confused over what the various properties of the radio button control do and how to generate the radio button correctly.

The ID property is key here.

You should set the ID property to a unique string that you then use to access the control on postback.

The GroupName is just an alias for the standard name property of a radio button and is used so when a user clicks on a radio button in a group only one radio button can be selected.

For example:

//add list to radio button list
RadioButton radioButton = new RadioButton();
radioButton.GroupName = "radioGroup";
radioButton.Text = singleType.appTypeID.ToString();
radioButton.ID = singleType.appTypeName;

radioArea.Controls.Add(radioButton);

Label label = new Label();
label.Text = "<br />";
radioArea.Controls.Add(label);

In the above example I've assigned singleType.appTypeName as the ID, assuming that this is unique.

Then to retrive the value on postback do this, assumnig that singleType.appTypeName = "mySuperApp":

RadioButton radioButton = (RadioButton) radioArea.FindControl("mySuperApp");

Now you can access the radioButton variable to check which GroupName it has, get it's value and check that it is checked.

You will need to loop over the radio buttons to find out which one is checked. An easy way of doing this is looping over the child controls of the radioArea and checking eack control to see if it is a radio button and if it is checked. Another options is to give each ID a prefix i.e. ID="RAD_"+singleType.appTypeName and loop over the Request object and match each one with the correct suffix.

9
ответ дан 9 December 2019 в 20:46
поделиться

Используемый вами метод FindControl ожидает, что вы передадите ему ID , который был назначен для управления при его создании.

в вашем примере RadioButton.ID должен быть равен singleType.appTypeID.ToString ()

Надеюсь, это поможет.

3
ответ дан 9 December 2019 в 20:46
поделиться
Другие вопросы по тегам:

Похожие вопросы: