Click here to Skip to main content
15,896,493 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have a record and i want to edit record and when i click on edit button i am showing old values in form for editing and there is also dropdownlist box in edit option there is office code and office name bound wigth ddl and i fill whole ddl items and value now i want that value of ddl is selected as user previously selected and value is stores in database i can show old values in text boxes but how to show old value in ddl
plz help mine code is in asp.net using VB
Posted

You can store the old value in a variable and then set the selectedvalue in the drop down to this value.
 
Share this answer
 
Comments
UD(IA) 25-Nov-13 17:42pm    
i do this but not work..
Dim office1 = read1("Office_Cd").ToString()
ddl_editOffice.SelectedValue = office1
UD(IA) 25-Nov-13 18:36pm    
'ddl_editOffice' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value

i got this type of error when i try to do this
office_Cd="01"
Dim sql1 As String = "select * from Office_Mast where Office_Cd='" & officeCd.Trim & "' order by Office_Name"
Dim cmd3 As New SqlCommand(sql1, conn)
Dim dr1 As SqlDataReader
dr1 = cmd3.ExecuteReader
ddl_editOffice.DataTextField = "Office_Name"
ddl_editOffice.DataValueField = "Office_Cd"
ddl_editOffice.DataBind()
ddl_editOffice.Items.Insert(0, "--Select--")
If dr1.IsClosed = False Then dr1.Close()
ddl_editOffice.SelectedValue = officeCd
always use trim function whenever we pick value from textvalue from database
 
Share this answer
 

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