Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
Hello Dears ,

i have 2 DropDownList ( ddl_List1 , ddl_List2 )

i will populate ddl_List1  from database (SQL SERVER) and i'm already done 

the second list ddl_List2 should filled from database as the following :

                Dim dr As System.Data.SqlClient.SqlDataReader 
                Dim RelatedDeptEmpListItem As New ListItem
                RelatedDeptEmpListItem.Value = -1
                RelatedDeptEmpListItem.Text = ""
                ddl_List2 Items.Add((RelatedDeptEmpListItem))
                Dim RelatedDeptEmpListCounter As Integer = 0
                dr = UsersInSignature.GetUsersInSignatures(ddl_List1.SelectedValue)
                While dr.Read
                    Dim UserInfo As New ListItem
                    UserInfo.Value = dr("UserID")
                    UserInfo.Text = dr("UserFullName")
                    ddl_List2.Items.Add((UserInfo))
                    RelatedDeptEmpListCounter = RelatedDeptEmpListCounter + 1
                End While
                dr.Close()
in this block of code the second list populated depends on the selected value of the first list .

THE PROBLEM IS :

when i click on save button the selected value of the second list LOST and the second list reloaded again 

so , how can i fix this problem and get the selected value of the second List


any idea please 

thanks 


What I have tried:

i tried the not ispostback and i tried to get the selected value in the load level
but nothing help me
Posted
Updated 16-May-16 2:44am
Comments
Richard Deeming 16-May-16 9:03am    
How are you calling the code that binds the lists? It sounds like you're calling it on every page load, without checking the Page.IsPostBack property. That will overwrite the selected item from the list.

1 solution

Set it to true, it should solve the problem.
 
Share this answer
 
Comments
DEV-MOK 17-May-16 4:01am    
not working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900