Now, I have solved my first problems which were to a) dynamically generate the DDLs (I used a wrapper class and overrode Render and AddAttributesToRender) and b) only hit the database once to generate and populate the DDLs, but now I would like to know which Item was selected in each of the DDLs on postback.
To summarize:
Public Class ItemPair
Inherits DropDownList
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
output.RenderBeginTag("form")
MyBase.Render(output)
End Sub
Protected Overrides Sub AddAttributesToRender(ByVal writer As HtmlTextWriter)
writer.RenderEndTag()
End Sub
End Class
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
If (Not Page.IsPostBack) Then
{create, populate, and add the ItemPairs to the Form}
Else
Dim cc As New Collection
cc = Session("PageControls")
Dim control As New Control
For Each control In cc
If control.ID <> "Form1" Then
Me.Controls.Add(control)
End If
Next
End Sub
Public Overrides Sub Dispose()
Dim control As New Control
Dim cc As New Collection
For Each control In Me.Controls
cc.Add(control)
Next
MyBase.Dispose()
End Sub
I tried making the AutoPostBack property of each ItemPair True while creating them but that didn't work. As a matter of fact I tried several different ways of making the ItemPairs' AutoPostBack proterty True and couldn't do it. I'm not even sure if that is the right tack to try.
All help is much appreciated.bump for more eyeballs
0 comments:
Post a Comment