"Konrad Hammerer" <ko************ *@tesis.dewrote in message
news:11******** *******@gzpc.te sis.de...
>Thanks for the link! But my problem was not the part of adding the
controls to the page but reading the values of them after the user has
clicked the button. As I mentioned:
The goal is to provide some textboxes *AND read the input data of them
in the "click"-ActionHandler of the button*!
Do you have some information on that part as well?
The 4Guys article describes all that...
hmmm, maybe I have missed something there... I will read it again!
Please post your code...
My code (+ explanation):
1)
fillFilters(): fills a combobox with some values
2)
If the user changes the value of the combobox
(cboFilters_Sel ectedIndexChang ed), paintTextBoxes( ) will add dynamically
rows, cells and textboxes within the cells to a table (added not by code
but with the designer). The Textboxes are filled with default values
which should be changed by the user!
3)
After entering the values, the user clicks a button
(btnExecuteFilt er_Click). After this, the function executeFilter()
should read the values but I cannot find/read the controls (rows, cells
and textboxes) -That is the problem!!!
Code:
Partial Class filter
Inherits System.Web.UI.P age
Private m_cDefaultLVStr ing As String = "(Parameterwert )"
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
If Session.Item("U ser") = "" Or Session.Item("P assword") = "" Then
Session.Add("La stError", "Es sind keine Anmeldedaten im System
hinterlegt!")
Response.Redire ct("./showerror.aspx" )
End If
If Not Me.IsPostBack Then
'
' get filters from database
'
fillFilters()
End If
lblError.Text = ""
End Sub
Private Sub fillFilters()
Dim oCol As Collection = Nothing
brlvDBHandler.g etFilters(Sessi on.Item("User") ,
Session.Item("P assword"), oCol)
For Each oFilter As brlvFilter In oCol
cboFilters.Item s.Add(oFilter.T oString())
Next
If oCol.Count 0 Then paintTextBoxes( CType(oCol.Item (1), brlvFilter))
End Sub
Protected Sub cboFilters_Sele ctedIndexChange d(ByVal sender As Object,
ByVal e As System.EventArg s) Handles cboFilters.Sele ctedIndexChange d
Dim oCol As Collection = Nothing
brlvDBHandler.g etFilters(Sessi on.Item("User") ,
Session.Item("P assword"), oCol)
For Each oFiler As brlvFilter In oCol
If cboFilters.Sele ctedItem.Text = oFiler.ToString Then
paintTextBoxes( oFiler)
End If
Next
End Sub
Private Sub paintTextBoxes( ByVal oFilter As brlvFilter)
Dim txt As TextBox
Dim oFilterParam As brlvFilterParam
Dim oRow As TableRow
Dim oCell1 As TableCell
Dim oCell2 As TableCell
Dim oCell3 As TableCell
oRow = New TableRow
oCell1 = New TableCell
oCell2 = New TableCell
oCell3 = New TableCell
For Each oFilterParam In oFilter.Params
'
' create and fill new textbox
'
txt = New TextBox
If oFilterParam.Na me = "Bezirksverband " And oFilterParam.Ty pe =
"Text" Then
txt.Text = Session.Item("B ezirksverband")
Else
txt.Text = m_cDefaultLVStr ing
End If
oRow = New TableRow
oCell1 = New TableCell
oCell2 = New TableCell
oCell3 = New TableCell
oCell1.Text = oFilterParam.Na me
oCell1.CssClass = "filter"
oCell2.Controls .Add(txt)
oCell2.CssClass = "filter"
oCell3.Text = "Parameter-Typ: " & oFilterParam.Ty pe
oRow.Cells.Add( oCell1)
oRow.Cells.Add( oCell2)
oRow.Cells.Add( oCell3)
tblParams.Rows. Add(oRow)
Next
End Sub
Protected Sub btnExecuteFilte r_Click(ByVal sender As Object, ByVal e
As System.EventArg s) Handles btnExecuteFilte r.Click
Dim oCol As Collection = Nothing
brlvDBHandler.g etFilters(Sessi on.Item("User") ,
Session.Item("P assword"), oCol)
For Each oFilter As brlvFilter In oCol
If cboFilters.Sele ctedItem.Text = oFilter.ToStrin g Then
paintTextBoxes( oFilter) ' geht so nicht, da sonst alle
User-Angaben wieder überschrieben werden! Und es ist auch irgendwie
unsinnig!
executeFilter(o Filter)
End If
Next
End Sub
Private Sub executeFilter(B yVal oFilter As brlvFilter)
Dim txt As TextBox
lblError.Text = ""
For Each oRow As TableRow In tblParams.Rows
txt = CType(oRow.Cell s.Item(1).Contr ols.Item(0), TextBox)
If txt.Text = m_cDefaultLVStr ing Then
lblError.Text = "Bitte geben Sie für den Parameter """ &
oRow.Cells.Item (0).Text & """ einen gültigen Wert an!"
Return
End If
Next
oFilter.SqlPara ms.Clear()
End Sub
End Class
>