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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get value from combo box using Request.Params

Status
Not open for further replies.

wtstro

Programmer
Aug 1, 2002
15
US
Here's my setup:

I have a web control, Criteria.ascx, that contains a form used to enter search criteria. The user fills in data for the fields they want to search on. Some are text boxes and some are dropdown lists.

When the form is submitted it loads the Search.aspx page. This is the page that will display the results of the search. This page has VB code behind:

[blue]
Dim strDAUser As String
Dim strIssueId As String

[green]'This is a combo box[/green]
If Len(Request.Params("cboDAUser")) > 0 Then
strDAUser = Request.Params("cboDAUser")
End If
[green]'This is a text box[/green]
If Len(Request.Params("txtIssueId")) > 0 Then
strIssueId = Request.Params("txtIssueId")
End If

[green]'Pass Search form parameters to PDMRequest.vb function[/green]
MyList.DataSource = oReqDB.GetResults(strDAUser, strIssueId)
MyList.DataBind()

[green]'Display a message to indicate results of search[/green]
If MyList.Items.Count = 0 Then
ResultMsg.Text = "No requests found in your search."
Else
ResultMsg.Text = "Your search returned " & _
MyList.Items.Count & " records."
End If[/blue]


When stepping through the code the "cboDAUser" always equals nothing. How do I capture the value assigned to the combo box when a selection is made?
 
wt: This is just a hip shot, since I have not used the request.params approach - but it seems it might be possible to substitute

Code:
'This is a combo box
If Len(Request.Params("cboDAUser")) > 0 Then
   strDAUser = Request.Params("cboDAUser")
End If

for...

If cboDAUser.SelectedIndex <> 0 Then
 strDAUser = cboDAUser.SelectedItem.Text
End If

Again, I may be missing something here, but it seems in your Search.aspx code behind this apporach should be practical -- although there appears no logical reason for the combo box not to behave similarly to the text box (there certainly appears to be a difference). Someone else may drop in a with a quick resolution.

 
Thanks, Isadore, for your response.

Unfortunately, that did not work. The cboDAUser combo box object actually resides on the calling page (Criteria.ascx) and used by the called page (Search.aspx). The need is to populate a variable on the Search.aspx page from the Criteria.ascx combo box object.

One thing I do not want to have to do is pass this value through the actual URL (i.e.,
 
Good post wt; we'll take a closer look at this; someone should drop by and put their 2 cents in.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top