2013-07-31 30 views
0

我创建动态单选按钮列表如何更改标识停止ASP.NET为了执行某些操作

Dim rdbQuestion As New RadioButtonList 

并有动态ID作为

rdbQuestion.ID = "Question_" & row("Id").ToString 

而当页面呈现单选按钮列表的ID更改为这样的东西

AssessmentPerforma_Question_1, AssessmentPerforma_Question_2, AssessmentPerforma_Question_3..... AssessmentPerforma_Question_n 

如何停止更改ID的asp.net S IN为了执行操作这样

Sub btnSave_click(ByVal sender As Object, ByVal e As EventArgs) 

     Dim rbl As RadioButtonList = DirectCast(Page.FindControl("Question_1"), RadioButtonList) 
     Response.Write(rbl.SelectedValue) 
End Sub 
+0

'C#'标签似乎毫无意义。 –

+0

你不需要 - 'FindControl'使用服务器端的ID,而不是ClientId。 –

回答

2

加入这一行....

rbdQuestion.ClientIDMode = ClientIDMode.Static 
+0

感谢您的帮助..但我得到“对象引用未设置为对象的实例”。 – adward

+0

在创建rbdQuestion的对象后添加此行。 –

+0

我已经做了同样的问题,但同样的问题..) – adward

相关问题