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

Drop Down List A via Drop Down List B

Status
Not open for further replies.

m0nty005

IS-IT--Management
Apr 24, 2004
27
US
Currently, my form does not commit the final execution (IsPostBack section)until all values are properly entered and the submit button is clicked. How do I populate DDL_B (ddlManagers) when I select/onchange a value from DDL_A (ddlCompanies)? There's 2 ways I cud think of:

(1) Populate server-side values (Manager) to client side javascript array & use client-side onchange method -or-
(2) If I can distinguish the autopostback for Submit button -vs- DDL_A Companies, then I can implement the proper code inside the IsPostBack section (the Else section).

---------------------------------------------------------
<script runat="server">
Sub Page_Load
If Not IsPostBack Then
ddlCompanies = list from db tbl_Company
ddlManagers = blank form for now
Else
Insert data into db tbl_Registration
End If
End sub
</script>

<form runat="Server">
<asp:Textbox id="tbxNewUserName" runat="server"></asp:Textbox>
<asp:DropDownList id="ddlCompanies" runat="server"></asp:DropDownList>
<asp:DropDownList id="ddlManagers" runat="server"></asp:DropDownList>
<asp:Button id="Button1" runat="server" Text="Submit"></asp:Button>
</form>
 
Hi

If you set the CausesValidation property of the Button to false and the AutoPostBack property of the DropDownList to true this will allow the DropDown to post back without causing validation. In your event handler for the Button Click event you include
Code:
this.Validate();
if(this.IsValid){
  // do stuff
}

Rob

Every gun that is made, every warship launched, every rocket fired, signifies in the final sense a theft from those who hunger and are not fed, those who are cold and are not clothed - Eisenhower 1953
 
If i set the DDL_A (Companies) to autopostback, then everytime i select a company, it would "INSERT data into tbl_Registration" which i don't want. I only want to "Insert --" once when everything is validated and button submitted. The problem i'm trying to solve is to autochange the DDL_B (Managers) whenever i select a different Company (and at the same time, the "INSERT --" should not be executed).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top