0
我試圖把一個 - 似乎什麼 - 很簡單的Web用戶控件添加事件以編程方式添加控件的Web用戶控件
基本上我希望它可以基於屬性 呈現爲一個下拉列表/ CheckBoxList的或單選列表但也想能夠找出選擇什麼
我正在嘗試以下 - 但似乎無法解決如何附加到listcontrol的selectedindexchanged,以便我可以設置選擇的值(s) 其沒有幫助,我的VB不是很多,但我不得不使用它在這種情況下,它甚至不給我intellisense爲e發泄..
Public Options As List(Of Options)
Public ControlRenderType As ControlRenderType
Public IncludeFreeOption As Boolean
Public SelectedOptions As List(Of Options)
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
Dim c As ListControl
Select Case (ControlRenderType)
Case STGLib.ControlRenderType.CheckBoxList
c = New CheckBoxList()
Case STGLib.ControlRenderType.DropdownList
c = New DropDownList()
Case STGLib.ControlRenderType.RadioButtonList
c = New RadioButtonList()
Case Else
Throw New Exception("No Render Type Specified")
End Select
For Each opt In Options
Dim li = New ListItem(opt.Description, opt.ID)
c.Items.Add(li)
Next
c.SelectedIndexChanged += ..?? or something
Page.Controls.Add(c)
End Sub
任何人都可以解釋請 - 這當然是完全可能的,我在完全錯誤的方式去了解這個..
感謝
謝謝,我想這是我失蹤的addhandler – nat 2012-07-18 12:29:31