[thelist] .NET multiple dynamically generated dropDownLists

Peter Brunone (EasyListBox.com) peter at easylistbox.com
Fri Sep 10 18:20:39 CDT 2004


	Inside the loop, you could say something like this:

If Request.Form(ddlCon) = "between" Then
	txt.Visible = True
Else
	txt.Visible = False
End If

	The code below seems like a rather old-school ASP approach to
generating a grid; have you considered a repeater or a datagrid?

Cheers,

Peter

-----Original Message-----
From: thelist-bounces at lists.evolt.org On Behalf Of Mark Joslyn

On postback!

Thanks,

markJ

-----Original Message-----
From: thelist-bounces at lists.evolt.org On Behalf Of Peter Brunone
(EasyListBox.com)

Mark,

	Do you want this to happen on the client or on postback?

http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ is another great
place to ask specialized ASP.NET questions like this.

Cheers,

Peter

-----Original Message-----
From: thelist-bounces at lists.evolt.org On Behalf Of Mark Joslyn

I am creating a front-end web application that builds a search form to
be filled out by the user to return search results from a web services
application.

Since the number of fields will vary form report to report, I need to
dynamically create the labels, textboxes and dropdownlists.

Here is how I am creating the form:

sub Page_Load(ByVal Sender as Object, ByVal e as EventArgs)
	' variables

	try	
		' web service connection code

		for each cc in bb.iInList
			Dim lbl as New Label()
			lbl.ID = "lbl_" & cc.inName.ToString
			Dim txt as New TextBox()		
			txt.ID = "txt_" & cc.inName.ToString
			txt.Width = Unit.Pixel(250)
			Dim ddlCon as New DropDownList()
			ddlCon.ID = "ddlCon_" & cc.inName.ToString
			ddlCon.AutoPostBack = true
			ddlCon.Width = Unit.Pixel(100)
								
			lbl.Text = cc.inName.ToString & ": "
	
'build table code (Table1)		
		next
	catch ex As System.Web.Services.Protocols.SoapException
		' catch SOAP errors code
	end try
end sub

(FYI - this code is drastically trimmed)

What happens is that the table (Table1) is written out like this: this
part is working!

Row
Cell1 = Label (lbl)
Cell2 = Contstructor (ddlCon)
Cell3 = Textbox (txt)
Cell4 = textbox (hidden)
end row

Next row, etc..

I need to be able to target a specific ddlCon - if a user selects
"between" from a ddlCon dropDownList, I need the Cell4 textbox to appear
- but only the Cell4 textbox in that row. Since all the dropDownLists
are dynamically generated, and have dynamically generated Ids, how can I
assign specific events to specific rows?

Any help would be appreciated.

Thanks,

markJ





More information about the thelist mailing list