This topic is locked

Making Dropdowns Hidden

6/19/2006 10:51:38 PM
ASPRunner.NET General questions
P
paul.speck author

Hello,
I am trying to hide certain fields on the Add/Edit forms for 1 table based on a dropdown field value on the same form using the template editor. I have not used the template editor before and am not sure where to edit.
I think what I am looking for is a way to set autopostback to true on certain dropdown fields, and in the postback code in on_load I need a way to reference fields specific to this table. When I code something similar to the following into the postback part of the Edit template on_load function:

----------------------------------------------------------

If "##SHORTTABLENAME##" = "table1" Then

'fldtable1field1.Visible = False'

End If

----------------------------------------------------------

I get an error when trying to edit any other table because it does not have a fldtable1field1. Maybe if there is a way to cycle through all ##SHORTFIELDNAME##'s for the current table, that would provide a work around?
Sorry for the broad question. If you need any more specifics let me know.

Thanks in advance for the help,

Paul

Eugene 6/21/2006

Paul,
At first, Template Editor is used for changes applied for all tables.
In this case you can use Table Events- Edit Page-OnLoad in wizard.
This code hide fldCustomerID field when fldEmployeeID is equal 3
Dim fldEmployeeID As System.Web.UI.WebControls.DropDownList = Page.FindControl("fldEmployeeID")

Dim fldCustomerID As System.Web.UI.WebControls.DropDownList = Page.FindControl("fldCustomerID")

If Not IsNothing(fldEmployeeID) AndAlso Not IsNothing(fldEmployeeID) Then

fldEmployeeID.AutoPostBack = True

fldCustomerID.Visible = (fldEmployeeID.SelectedValue <> "3")

End If

P
paul.speck author 6/21/2006

Eugene,
Thank you for the help. That is exactly what I was looking for. I will try this out and let you know if I come across any problems.
Thanks agian,

Paul