J
jbeckh2
Hi,
I am trying to create a custom server control that contains several
dropdownlists. The control looks like this:
Dim pnlHeader As New Panel
Protected Overrides Sub RenderContents(ByVal writer as HtmlTextWriter)
pnlHeader.RenderControl(writer)
End Sub
Public Sub Setup_Control()
Dim table As New HtmlControls.HtmlTable
table.Attributes.Add("style", "width:100%")
pnlHeader.Controls.Add(table)
Dim row As New HtmlControls.HtmlTableRow
Dim cellLabel As New HtmlControls.HtmlTableCell
cellLabel.Width = "60%"
Dim lblProblems As New Label
lblProblems.ID = "lbl" & Category.ProblemTypeId
lblProblems.Text = "Choose Vendor for All " &
Category.ProblemType & " Problems."
cellLabel.Controls.Add(lblProblems)
Dim cellDDL As New HtmlControls.HtmlTableCell
cellDDL.Width = "30%"
Dim ddlAll As New DropDownList
ddlAll.ID = "ddlVendorForAll" &
Category.ProblemTypeId.ToString()
ddlAll.AutoPostBack = True
Common.FillList(ddlAll, HeatMapData.GetVendors(PropertyId,
"[Choose a Vendor]"))
cellDDL.Controls.Add(ddlAll)
listDDL.Add(ddlAll)
AddHandler ddlAll.SelectedIndexChanged, AddressOf
ddlAll_SelectedIndexChanged
Dim cellImage As New HtmlControls.HtmlTableCell
cellImage.Width = "9%"
Dim imgExpand As New WebControls.Image
imgExpand.ID = "imgExpand" &
Category.ProblemTypeId.ToString()
imgExpand.ImageUrl = "~/images/icons/118.png"
imgExpand.ToolTip = "View Details"
Dim imgCollapse As New WebControls.Image
imgCollapse.ID = "imgCollapse" &
Category.ProblemTypeId.ToString()
imgCollapse.ImageUrl = "~/images/icons/116.png"
imgCollapse.ToolTip = "Hide Details"
imgCollapse.Attributes.Add("style", "display:none")
cellImage.Controls.Add(imgExpand)
cellImage.Controls.Add(imgCollapse)
row.Controls.Add(cellLabel)
row.Controls.Add(cellDDL)
row.Controls.Add(cellImage)
table.Rows.Add(row)
pnlHeader.BackColor = Drawing.Color.FromArgb(255, 206,
204, 204)
End Sub
Protected Sub ddlAll_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs)
....
End Sub
The control renders fine. The problem I am having is that the
dynamically created dropdownlist (ddlAll) does not fire the
SelectedIndexChanged event. What am I missing?
Thanks,
Jeremy
I am trying to create a custom server control that contains several
dropdownlists. The control looks like this:
Dim pnlHeader As New Panel
Protected Overrides Sub RenderContents(ByVal writer as HtmlTextWriter)
pnlHeader.RenderControl(writer)
End Sub
Public Sub Setup_Control()
Dim table As New HtmlControls.HtmlTable
table.Attributes.Add("style", "width:100%")
pnlHeader.Controls.Add(table)
Dim row As New HtmlControls.HtmlTableRow
Dim cellLabel As New HtmlControls.HtmlTableCell
cellLabel.Width = "60%"
Dim lblProblems As New Label
lblProblems.ID = "lbl" & Category.ProblemTypeId
lblProblems.Text = "Choose Vendor for All " &
Category.ProblemType & " Problems."
cellLabel.Controls.Add(lblProblems)
Dim cellDDL As New HtmlControls.HtmlTableCell
cellDDL.Width = "30%"
Dim ddlAll As New DropDownList
ddlAll.ID = "ddlVendorForAll" &
Category.ProblemTypeId.ToString()
ddlAll.AutoPostBack = True
Common.FillList(ddlAll, HeatMapData.GetVendors(PropertyId,
"[Choose a Vendor]"))
cellDDL.Controls.Add(ddlAll)
listDDL.Add(ddlAll)
AddHandler ddlAll.SelectedIndexChanged, AddressOf
ddlAll_SelectedIndexChanged
Dim cellImage As New HtmlControls.HtmlTableCell
cellImage.Width = "9%"
Dim imgExpand As New WebControls.Image
imgExpand.ID = "imgExpand" &
Category.ProblemTypeId.ToString()
imgExpand.ImageUrl = "~/images/icons/118.png"
imgExpand.ToolTip = "View Details"
Dim imgCollapse As New WebControls.Image
imgCollapse.ID = "imgCollapse" &
Category.ProblemTypeId.ToString()
imgCollapse.ImageUrl = "~/images/icons/116.png"
imgCollapse.ToolTip = "Hide Details"
imgCollapse.Attributes.Add("style", "display:none")
cellImage.Controls.Add(imgExpand)
cellImage.Controls.Add(imgCollapse)
row.Controls.Add(cellLabel)
row.Controls.Add(cellDDL)
row.Controls.Add(cellImage)
table.Rows.Add(row)
pnlHeader.BackColor = Drawing.Color.FromArgb(255, 206,
204, 204)
End Sub
Protected Sub ddlAll_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs)
....
End Sub
The control renders fine. The problem I am having is that the
dynamically created dropdownlist (ddlAll) does not fire the
SelectedIndexChanged event. What am I missing?
Thanks,
Jeremy