S
stephen
Hi,
I have a place holder and I have a checkboxlist in it?
why do i get a "System.NullReferenceException: Object reference not set to
an instance of an object." error why I try to get the selected value from
it?
Thanks,
Stephen
here is what I am doing?
Dim chkBoxList As CheckBoxList
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
ShowCheckBoxes()
btn_Select.Text = "Display Selected"
End If
End Sub
Private Sub ShowCheckBoxes()
Dim tString As String = "12px"
chkBoxList = New CheckBoxList
chkBoxList.Items.Add(New ListItem("Is Enabled", "IsEnabled"))
chkBoxList.Items.Add(New ListItem("Is Active", "IsActive"))
chkBoxList.RepeatColumns = 2
chkBoxList.RepeatDirection = RepeatDirection.Horizontal
chkBoxList.Font.Size = FontUnit.Parse(tString)
phCheckButtons.Controls.Add(chkBoxList)
End Sub
Private Sub btn_Select_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_Select.Click
If chkBoxList.SelectedItem.Text = "Is Enabled" Then
Response.Write("<script language='javascript'> { alert('Check Box
Selected.') }</script>")
End If
End Sub
I have a place holder and I have a checkboxlist in it?
why do i get a "System.NullReferenceException: Object reference not set to
an instance of an object." error why I try to get the selected value from
it?
Thanks,
Stephen
here is what I am doing?
Dim chkBoxList As CheckBoxList
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
ShowCheckBoxes()
btn_Select.Text = "Display Selected"
End If
End Sub
Private Sub ShowCheckBoxes()
Dim tString As String = "12px"
chkBoxList = New CheckBoxList
chkBoxList.Items.Add(New ListItem("Is Enabled", "IsEnabled"))
chkBoxList.Items.Add(New ListItem("Is Active", "IsActive"))
chkBoxList.RepeatColumns = 2
chkBoxList.RepeatDirection = RepeatDirection.Horizontal
chkBoxList.Font.Size = FontUnit.Parse(tString)
phCheckButtons.Controls.Add(chkBoxList)
End Sub
Private Sub btn_Select_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_Select.Click
If chkBoxList.SelectedItem.Text = "Is Enabled" Then
Response.Write("<script language='javascript'> { alert('Check Box
Selected.') }</script>")
End If
End Sub