0

I want to populate the dropdownlist ddVerantwortlich1 with the people with the proper credentials based on the selected process step ddProzessschritt1

It doesn't work if I want to change it using datasource and databind i have to manually loop through the table in the dataset returned from the query. then it works. but not otherwise...

What's the problem? Here my code:

Protected Sub ddProzessschritt1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddProzessschritt1.SelectedIndexChanged
    'StefanSteiger.Debug.MsgBox("index changed!")

    Dim dsProcessResponsibleDataSet As Data.DataSet = New DataSet
    Dim strSQL As String = "SELECT BE_ID, (BE_Name + ' ' +BE_Vorname) as UserName FROM T_Benutzer WHERE BE_ID IN "
    strSQL += "(SELECT BEBG_BE FROM T_Benutzer_Benutzergruppen WHERE BEBG_BG IN "
    strSQL += "(SELECT ZO_BG_ID FROM T_DMS_ZO_Prozesse_Berechtigungen WHERE ZO_PROC_UID = '" + ddProzessschritt1.SelectedValue.ToString + "')) ORDER BY UserName"

    If StefanSteiger.DBcmds.GetDataSet(strSQL, dsProcessResponsibleDataSet) > 0 Then
        Me.ddVerantwortlich1.Items.Clear()
        For Each row As Data.DataRow In dsProcessResponsibleDataSet.Tables(0).Rows
            'StefanSteiger.Debug.MsgBox(row("UserName").ToString + " ¦ " + row("BE_ID").ToString)
            ddVerantwortlich1.Items.Add(New ListItem(row("UserName"), row("BE_ID")))
        Next
        'Me.ddVerantwortlich1.Dispose()
        'Me.ddProzessschritt1.DataSource = dsProcessResponsibleDataSet.Tables(0)
        'Me.ddVerantwortlich1.DataTextField = "UserName"
        'Me.ddVerantwortlich1.DataValueField = "BE_ID"
        'Me.ddVerantwortlich1.DataBind()
    Else
        'Me.ddProzessschritt1.Dispose()
        ddVerantwortlich1.Items.Add(New ListItem("Niemand verantwortlich.", Nothing))
    End If
End Sub
2
  • At first glance I don't see the problem. Can you elaborate on the unwanted behavior you are experiencing? What do you see when debugging (is the data set populated? is the code block that populates the DDL executed?). Commented Aug 28, 2009 at 18:24
  • Is this a web app (ASP.NET) or a desktop app (WinForms)? Postbacks and loasing state may be your problems if it's a web app. Commented Oct 26, 2009 at 17:55

1 Answer 1

1

Why you call Dispose on the DropDown? Maybe that's the problem. Give it a try!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.