Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add second text box when "between" is selected

Status
Not open for further replies.

arada1

MIS
Dec 3, 2006
47
US
hi all,
when a user select between clasue from the operatorselector dropdown I would like to add another text box otherwise I have one text box for the rest of the operators. how can I acomplish this. thanks




Sub OperatorSelector()

Dim opSelector As ArrayList
opSelector = New ArrayList

opSelector.Add("<")
opSelector.Add("<=")
opSelector.Add("=")
opSelector.Add(">")
opSelector.Add(">=")
opSelector.Add("Between")
opSelector.Insert(0, "--Select Operator--")
drOperator.DataSource = opSelector
drOperator.DataBind()

End Sub



will this work for me
Protected Sub drOperator_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles drOperator.SelectedIndexChanged
If drOperator.SelectedValue.ToString = "Between" Then
lblMax.Visible = True
txtMax.Visible = True
Else

End If
End Sub
 
yes, it did not work for me...
here is what i have on page load


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
FedProjYear()
OperatorSelector()
lblMax.Visible = False
txtMax.Visible = False
District()

End If

End Sub
 
Step through you code and see if that event is fired and your code is being hit.
 
jbenson001 as you suggested i setp through and the visible value for the textbox and lable changed to true in the code but when I run the page I am not still seeing the text box and label...
 
Then somewhere else after that code they are being set to visible=False
Check this sub:District() it is called after you set them to visible = TRUE..
 
jbenson001 thank you for your time..I checked my entire code and the only place I set them to false in during the page load event. thank you again
here is my entire code
Imports System.Data
Imports System.Data.OracleClient
Imports System.Configuration.ConfigurationManager
Imports System.Web.UI.WebControls
Partial Class lettingReport_federalPr
Inherits System.Web.UI.Page



Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
FedProjYear()
OperatorSelector()
lblMax.Visible = False
txtMax.Visible = False
District()

End If

End Sub


Sub FedProjYear()
Dim FedPrYear As ArrayList
FedPrYear = New ArrayList

FedPrYear.Add("1999")
FedPrYear.Add("2000")
FedPrYear.Add("2001")
FedPrYear.Add("2002")
FedPrYear.Add("2003")
FedPrYear.Add("2004")
FedPrYear.Add("2005")
FedPrYear.Add("2006")
FedPrYear.Add("2007")
FedPrYear.Insert(0, "--Select year--")
drYear.DataSource = FedPrYear
drYear.DataBind()

End Sub

Sub OperatorSelector()

Dim opSelector As ArrayList
opSelector = New ArrayList

opSelector.Add("<")
opSelector.Add("<=")
opSelector.Add("=")
opSelector.Add(">")
opSelector.Add(">=")
opSelector.Add("Between")
opSelector.Insert(0, "--Select Operator--")
drOperator.DataSource = opSelector
drOperator.DataBind()

End Sub

Sub District()

Dim myDistrict = New SortedList
myDistrict.Add("1", "District 1")
myDistrict.Add("2", "District 2")
myDistrict.Add("3", "District 3")
myDistrict.Add("4", "District 4")
myDistrict.Add("6", "District 6")
myDistrict.Add("7", "District 7")
myDistrict.Add("8", "District 8")
myDistrict.Add("M", "Metro")
myDistrict.add("0", "--District--")
ddlDistrict.DataSource = myDistrict
ddlDistrict.DataValueField = "Key"
ddlDistrict.DataTextField = "Value"
ddlDistrict.DataBind()


End Sub
Protected Sub drOperator_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles drOperator.SelectedIndexChanged
If drOperator.SelectedValue.ToString = "Between" Then
lblMax.Visible = True
txtMax.Visible = True
Else

End If
End Sub
Protected Sub btnFederalProject_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnFederalProject.Click
' bindData("pjprjnum")
bindData()
End Sub
' Sub bindData(ByVal strSortedField As String)
Sub bindData()
gvFederal.Visible = True

'Dim dtrFederal As OracleDataReader

Dim opSelector As String = drOperator.SelectedItem.ToString
Dim LetYr As String = drYear.SelectedItem.ToString
Dim district As String = ddlDistrict.SelectedValue.ToString

'Dim oOracleConn As OracleConnection
Dim connectionString As String = ConnectionStrings("costEstimating").ConnectionString
Dim oOracleConn As OracleConnection = New OracleConnection(connectionString)
oOracleConn.Open()
Dim strStringBuilder As StringBuilder
strStringBuilder = New StringBuilder

strStringBuilder.Append("SELECT DISTINCT min(p.pjprjnum) ""Project Number"", TO_CHAR (l.contamt, '$99,999,999.99') AS ""DollarValue"",P.PJDISTR ""District"",")
strStringBuilder.Append(" cdescr ""Job Description"", (clocat1 ||' '|| clocat2) ""Location"" ")
strStringBuilder.Append(" FROM project p, letprop l, propproj j, bidlet b, proposal r ")
strStringBuilder.Append(" WHERE(j.pcn = p.pcn) AND l.lcontid = r.contid")
strStringBuilder.Append(" AND j.contid = l.lcontid AND b.letting = l.letting")
strStringBuilder.Append(" AND NOT (REPLACE (pjprjnum, ' ', '')) LIKE '%/STATEFUNDS'")
strStringBuilder.Append(" AND l.letstat = 'A'")
strStringBuilder.Append(" AND TO_CHAR (datelet, 'YYYY') = " & LetYr)
strStringBuilder.Append(" AND P.PJDISTR = '" & district & "'")
If opSelector = "Between" Then
strStringBuilder.Append(" AND l.contamt " & opSelector & " :Amount")
strStringBuilder.Append(" AND " & " :Amount1")
Else
strStringBuilder.Append(" AND l.contamt " & opSelector & ":Amount")
End If

strStringBuilder.Append(" group by l.contamt,p.pjdistr, cdescr,clocat1,clocat2")
strStringBuilder.Append(" Order by 2,1 ")

Dim cmdFederal As OracleCommand = New OracleCommand()
cmdFederal.Parameters.AddWithValue(":Amount", Trim(txtAmount.Text))
If opSelector = "Between" Then
cmdFederal.Parameters.AddWithValue(":Amount1", Trim(txtAmount.Text))
End If
cmdFederal.Connection = oOracleConn
cmdFederal.CommandText = strStringBuilder.ToString
cmdFederal.CommandType = CommandType.Text

Dim adpFederal As New OracleDataAdapter(cmdFederal)
Dim myDataSet As New DataSet
adpFederal.Fill(myDataSet, "FedProject")
gvFederal.DataSource = myDataSet

gvFederal.DataBind()


End Sub
Protected Sub gvFederal_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles gvFederal.PageIndexChanging
gvFederal.PageIndex = e.NewPageIndex
bindData()
End Sub

Protected Sub ckPage_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ckPage.CheckedChanged
If ckPage.Checked = True Then
gvFederal.PageSize = 1000000
Else
gvFederal.PageSize = 15
End If
End Sub

Protected Sub gvFederal_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvFederal.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim lowBid As Decimal = CType(DataBinder.Eval(e.Row.DataItem, "DollarValue"), Decimal)
If lowBid > 1000000 Then
e.Row.BackColor = Drawing.Color.LightSkyBlue
End If
End If
End Sub


End Class
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top