Formview级联下拉问题

时间:2014-09-24 16:04:35

标签: asp.net drop-down-menu formview cascadingdropdown

我正在使用Formview,在EditTemplate中,我有一个下拉列表依赖于另一个下拉列表值。 我看了一些例子,发现这个例子最简洁,我正在努力:

http://mikepope.com/blog/AddComment.aspx?blogid=1629 它非常直接,但它不适用于我的ddl。你能告诉我我错过了什么或没有正确实施吗?我已经删除了一些代码以便进行故障排除,但仍然没有。例如,我没有设置selectedValue,因为没有返回任何内容...

任何建议都将不胜感激。 感谢

HTML:

<EditItemTemplate>
...
...
...
<tr>
 <td colspan="6" align="left">
  <asp:DropDownList ID="ddTeams" runat="server" CssClass="myDropDownIndent" DataSourceID="sqlGetTeams" DataTextField="Team" DataValueField="Team" SelectedValue='<%# DetermineTeamValue(Eval("Team")) %>' AutoPostBack="true" OnSelectedIndexChanged="DropDownList_SelectedIndexChanged">
  </asp:DropDownList>
 </td>

 <td colspan="4" align="left">
  <asp:DropDownList ID="DropDownOwner" runat="server" CssClass="myDropDown" DataSourceID="sqlGetMembers2" DataTextField="EmployeeName" DataValueField="EmployeeName"                                                                                 OnSelectedIndexChanged="DropDownList_SelectedIndexChanged">
  </asp:DropDownList>

   <asp:SqlDataSource ID="sqlGetMembers2" runat="server"                                         ConnectionString="<%$ ConnectionStrings:ProjectDashboardConnectionString %>" 
SelectCommand="usp_GetMembers" SelectCommandType="StoredProcedure">
<SelectParameters>                
   <asp:Parameter Name="Type" />
   <asp:Parameter Name="TeamID" />                                            
 </SelectParameters>
 </asp:SqlDataSource>

</td>
</tr>

代码背后:

Protected Sub fvTask_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles fvTask.DataBound

            If fvTask.CurrentMode = FormViewMode.Edit Then
                Dim dv As System.Data.DataRowView = fvTask.DataItem
                Dim ddTeams2 As DropDownList = fvTask.FindControl("ddTeams")

                Dim DropDownOwner As DropDownList = fvTask.FindControl("DropDownOwner")
                Dim a As String = "A"                
                Dim dsc As SqlDataSource = fvTask.FindControl("sqlGetMembers2")

                dsc.SelectParameters("TeamID").DefaultValue = String.Empty
                dsc.SelectParameters("Type").DefaultValue = String.Empty
                DropDownOwner.DataBind()

                'If Not IsDBNull(dv("EmployeeName")) Then
                '    DropDownOwner.SelectedValue = dv("EmployeeName")
                'End If
            End If

        Catch ex As Exception
            ErrMessage = ex.ToString
        End Try

    End Sub

所以,我的第二个下拉列表为空。

0 个答案:

没有答案