Subject: Problems with placeholder and textboxes
Posted By: sean Post Date: 1/13/2004 10:49:22 AM
I have a framepage(index.htm) which calls a 100% webform(one.aspx) which then contains two iframe webforms(a.aspx, b.aspx).

Now, in a.aspx, i have a treeview with checkboxes, next to each of the items. On check of each of these checkboxes, i pass the selected values to b.aspx, by using javascript and the top frame to pass values inbetween the pages.

For example, if the user checks on Name, Age and Gender in the treeview, i populate the same in b.aspx. Now i want to be able to let the user add conditions to these.

these conditions could be  
Age : Greater than 20 and Less than 40
Gender : Male
Name : Contains Steve

But my problem is what is the best way to display Name, Age and Gender and populate a dropdown next to each of them and then based selection of each of these dropdown selected, one textbox or two textboxes should be displayed, depending on whether it is a range or a single value.

I am using a placeholder to generate columns, and row would have Age, Gender and Name, and a dropdown in the next column which would be contain the conditions. And then based on the condition, either one textbox would be made visible or two, depending on which condition is selected.

Now, i am facing this problem, as i have generated the dropdown which gets a feed from the dB, i can seem to access the individual textboxes in the placeholder.

my code is as follows:
PLACEHOLDER CODE
            ' Add Table Literal Control
            litLabelfiller = New LiteralControl
            litLabelfiller.Text = "<table border='0' width='100%' cellpadding='3' cellspacing='0'><tr><td align='left' valign='top'>"
            phCondition.Controls.Add(litLabelfiller)

            ' Add TextBox Control
            txtColumnP = New TextBox
            txtColumnP.ID = "txtColumn" & strFieldNum
            If Not FieldName = "" Then
                txtColumnP.Text = FieldName
            End If
            txtColumnP.Width = Unit.Pixel(100)
            txtColumnP.BorderWidth = Unit.Pixel(0)
            phCondition.Controls.Add(txtColumnP)

            ' Add DropDownList Control
            ddCondition = New DropDownList
            ddCondition.ID = "ddCondition" & strFieldNum
            ddCondition.AutoPostBack = True
            AddHandler ddCondition.SelectedIndexChanged, AddressOf PopulateTextBoxes
            populate_condition(ddCondition)
            phCondition.Controls.Add(ddCondition)

            ' Add TextBox Control
            txtRange1 = New TextBox
            txtRange1.ID = "txtRange1" & strFieldNum
            txtRange1.Visible = True
            txtRange1.Width = Unit.Pixel(100)
            phCondition.Controls.Add(txtRange1)

            ' Add TextBox Control
            txtRange2 = New TextBox
            txtRange2.ID = "txtRange2" & strFieldNum
            txtRange2.Visible = True
            txtRange2.Width = Unit.Pixel(100)
            phCondition.Controls.Add(txtRange2)

            ' Add Closing Table Spacer Literal Control
            litLabelfiller = New LiteralControl
            litLabelfiller.Text = "</td></tr></table>"
            phCondition.Controls.Add(litLabelfiller)

and the METHOD to access the dropdown, for example if the value of the dropdown is 8 or 9, then i need to make two textboxes visible as the condition would be a range rather than just one value.

    Sub PopulateTextBoxes(ByVal sender As Object, ByVal e As EventArgs)
        Try
            Dim c As Control
            Dim dd As DropDownList
            Dim txt1 As TextBox
            Dim txt2 As TextBox
            For Each c In phCondition.Controls
                If c.GetType Is GetType(DropDownList) Then
                    dd = CType(c, DropDownList)
                    Response.Write("Dropdown " & dd.SelectedItem.Value & "<br>")
                    If dd.SelectedItem.Value = 8 Or dd.SelectedItem.Value = 9 Then
                        Dim cName As String = CType(phCondition.FindControl("txtRange1"), TextBox).Text
                        ' this is where i need to make the txtRange1 and txtRange2 textboxes are made visible
                    Else
                        ' make only txtRange1 textboxes are made visible

                    End If
                End If
            Next
        Catch ex As Exception
            lberror.Text = ex.Message & "<br>" & ex.Source & "<br>" & ex.StackTrace
        End Try
    End Sub

any suggestions/advice is welcomed.

Thank you


Go to topic 8491

Return to index page 970
Return to index page 969
Return to index page 968
Return to index page 967
Return to index page 966
Return to index page 965
Return to index page 964
Return to index page 963
Return to index page 962
Return to index page 961