为什么我的下拉列表会继续返回下拉列表中的第一项?

时间:2017-05-02 14:59:04

标签: asp.net vb.net telerik

我在vb.net应用程序中有一个下拉列表,它也使用了radwindow作为模态。我在if not ispostback方法中有下拉数据绑定,但是当我选择一个值并运行它时,它仍然返回第一个项目。我尝试将autopostback设置为true,但这样做也会关闭radwindow。还有其他工作吗?

 <telerik:RadWindow RenderMode="Lightweight" ID="winComments" runat="server" Title="Comments" RestrictionZoneID="ContentTemplateZone" Modal="true" Width="600" Skin="Outlook"
                        Height="550" Animation="Fade" Left="600" Top="100" CenterIfModal="true" EnableShadow="true" EnableViewState="false">
                        <ContentTemplate>
                            <div class="col-sm-12 col-xs-12">
                                <br />
                                <div class="col-sm-4 col-xs-4">
                                    <asp:Label ID="lblCommentVin" runat="server" Font-Bold="true" Visible="true"></asp:Label>
                                </div>
                                <div class="col-sm-5 col-xs-5">
                                    Department:
                                    <asp:DropDownList ID="ddlDepartments" runat="server"></asp:DropDownList>
                                </div>
                            </div>
                            <div class="col-xs-12">
                                <br />
                                <asp:TextBox ID="txtComment" runat="server" Text="" Height="300px" Width="550px" TextMode="MultiLine"></asp:TextBox>
                            </div>

                            <br />

                            <div class="col-md-offset-4">
                                <asp:ImageButton ID="btnCancel" runat="server" ImageUrl="images/btnCancel.png" OnClick="btnCancel_Click" CssClass="btn btn-sm pull-right" />
                                <asp:ImageButton ID="btnSave" runat="server" ImageUrl="images/btnSave.png" OnClick="btnSave_Click" CssClass="btn btn-sm pull-right" />
                            </div>
                        </ContentTemplate>
                    </telerik:RadWindow>

和背后的代码:

 If Not IsPostBack Then
 lblCommentVin.Text = vin
    commentDeptList = SQLData.getAssignedCommentDepartments(Session("user"))

    _departments = New DepartmentRepository().GetAll()
    Session("Departments") = _departments

    For Each dept As String In commentDeptList
        ddlDepartments.Items.Add(New ListItem(dept, dept))
    Next
    ddlDepartments.DataBind()

代码停止工作,我试图获取selecteditem

 Protected Sub btnSave_Click(sender As Object, e As ImageClickEventArgs)
    If txtComment.Text.Length > 1 Then
        Dim DepartmentName As String = ddlDepartments.SelectedItem.ToString

0 个答案:

没有答案