retrive preselected value in second drop down list from the first drop down list

retrive preselected value in second drop down list from the first drop down list

Post by weiwe » Sun, 07 Jan 2007 04:29:24


i
here is my scenario, I create a drop down list in itemtemplate.(that
drop down is created from db), after user
click edit command, my ideal plan is have another drop down list in
edititemtemplate with preselected value from
the previous drop down list, so far I can only achieved with the
regular drop down list in edititemtemplate with no preselected value
from previous one. anyone can help me.
thanks in advance. below is my current sample code.

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<script language="VB" runat="server">

Dim objConnection As SqlConnection
Dim myDataReader As SqlDataReader

Sub Page_Load(Sender As Object, E As EventArgs)
' Set up our connection.
objConnection = New SqlConnection("Data Source=sql;Initial
Catalog=pub;User Id=xxx;Password=xxxxx;")

LoadDataFromDB

If Not IsPostBack Then
DataBindGrid
End If

End Sub

Sub LoadDataFromDB()
Dim objCommand As SqlCommand

' Create new command object passing it our SQL query and
telling it which connection to use.
objCommand = New SqlCommand("SELECT * FROM Educationtraining
WHERE Username = 'weifon888';", objConnection)

' Open the connection, execute the command, and close the connection.
objConnection.Open()
myDataReader =
objCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
End Sub

Sub DataBindGrid()
DBEditDataGrid.DataSource = myDataReader
DBEditDataGrid.DataBind
End Sub


'----------------------------------------------------------------------------------------------
Sub DBEditDataGrid_Edit(Sender As Object, E As
DataGridCommandEventArgs)
DBEditDataGrid.EditItemIndex = E.Item.ItemIndex
DataBindGrid
End Sub

Sub DBEditDataGrid_Cancel(Sender As Object, E As
DataGridCommandEventArgs)
DBEditDataGrid.EditItemIndex = -1
DataBindGrid
End Sub

Sub DBEditDataGrid_Update(ByVal Sender As Object, ByVal E As
DataGridCommandEventArgs)
' Since the textboxes are autogenerated we don't know their
names, but we do know their positions.
Dim Tempdroplist As DropDownList
Dim Tempdropvalue As String

Dim strUser As String = E.Item.Cells(0).Text
Dim certother As TextBox = E.Item.Cells(1).Controls(0)
Dim strcertother = Replace(certother.Text, "'", "`")

Tempdroplist = E.Item.FindControl("teachercert")
Tempdropvalue = Tempdroplist.SelectedItem.Value

Response.Write(strUser)
Response.Write(strcertother)
Response.Write(Tempdropvalue)


' Update the appropriate record in our database.
Dim objCommand As SqlCommand
Dim strSQLQuery As String

' Build our update command.
strSQLQuery = "UPDATE Educationtraining SET Certother = '" &
strcertother & "' WHERE Username = 'johndoe'"

' Create new command object passing it our SQL query and
telling it which connection to use.
objCommand = New SqlCommand(strSQLQuery, objConnection)

' Close our open DataReader
myDataReader.Close()

Try
' Execute the command
objConnection.Open()
objCommand.ExecuteNonQuery()
objConnection.Close()

Catch Ex As Exception

Finally
objCo
 
 
 

1. Using one drop down list to dynamically populate another drop down list

2. How do i have one Drop down list reference another drop down list

I have set up a form on the second sheet of a workbook. The first sheet
contains all relevent information for clients(in my case physicians). On the
second sheet i have set up a form, which will be used in the office, that has
a combo box list (i used the one available in the forms toolbar, as i do not
have the coding experience to use the ones in the control toolbox). This
list references the project name, and the cell reference is cell n1. I then
used the vlookup function to reference cell n1 and find the equivalent match
within sheet 1 using identifiers for each reference. ie project one (the
first option in the dropdown list) has an identifier of 1 within sheet one.
So if the value in N1 is 1 then all of the vlookup functions in the rest of
the form return the equivalent value for Idenfier 1 from Sheet 1. So in
essence whenever i change the Project name, all data in the form changes to
the corresponding identifier reference. However each project has different
clients with in it. SO when i choose a project is automatically returns the
first name with that identifier. My question is how do i make another combo
box which references the previous list and returns only the clients that have
that common project name. Any help is appreciated. I have visited the
contextures website which i have seen referenced here often and am throughly
confused. Thanks again and sorry for the wordiness.

3. Using one drop down list to dynamically populate another drop down list

4. update second drop down list box when the first drop down is updat

5. Drop-down List where items in drop-down list hyperlink to a webpage?

6. How to create drop down list that determines another drop down list?

7. Drop Down List choice selecting another drop down list

8. drop down list based on other drop down list pick

9. Drop-down List where items in drop-down list hyperlink to a webpag

10. Drop down list from another drop down list in Word?

11. Drop down list from another drop down list

12. Drop Down list predicated on other drop down lists

13. Drop-down list from drop-down list

14. Populate E-mail Drop Down List based on other Drop Down List

15. can you make a drop down list in a drop down list?