在模态中添加表单

时间:2015-06-18 01:51:38

标签: c# asp.net modal-dialog

我在模态中添加了一个表单。该模式包含2个下拉列表,4个文本框(1个隐藏)和一个用于添加的按钮。

我绑定项目类别的下拉列表,然后绑定我的项目名称的其他下拉列表。但是,当我在下拉列表中更改项目类别时,我的项目名称的下拉列表没有响应或没有绑定。任何人都可以帮助我吗?



<div id="addModal" class="modal fade">
  <div class="modal-dialog modal-md">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Add Item</h4>
      </div>
      <div class="modal-body">
        <div class="form-inline form-group">
          <asp:Label ID="Label1" CssClass="control-label col-xs-3" runat="server" Text="Category:"></asp:Label>
          <div class="col-xs-offset-3">
            <asp:DropDownList ID="drpCategory" runat="server" CssClass="form-control col-xs-5" OnTextChanged="drpCategory_TextChanged" />
          </div>

        </div>
        <div class="form-inline form-group">
          <asp:Label ID="Label2" CssClass="control-label col-xs-3" runat="server" Text="Item Name:"></asp:Label>
          <div class="col-xs-offset-3">
            <asp:TextBox ID="txtitem" runat="server" CssClass="form-control col-xs-5" Visible="false" />
            <asp:DropDownList ID="drpItem" runat="server" CssClass="form-control col-xs-5" Visible="true" />
          </div>
        </div>
        <div class="form-inline form-group">
          <asp:Label ID="Label3" CssClass="control-label col-xs-3" runat="server" Text="Unit:"></asp:Label>
          <div class="col-xs-offset-3">
            <asp:TextBox ID="txtUnit" runat="server" CssClass="form-control col-xs-5" Enabled="false" />
          </div>
        </div>
        <div class="form-inline form-group">
          <asp:Label ID="Label4" CssClass="control-label col-xs-3" runat="server" Text="Quantity:"></asp:Label>
          <div class="col-xs-offset-3">
            <asp:TextBox ID="txtQty" runat="server" CssClass="form-control col-xs-3" type="number" min="1" onkeypress="return isNumberKey(event)" />
          </div>
        </div>
      </div>
    </div>
    <div class="modal-footer">
      <asp:Button runat="server" ID="btnADD" CssClass="btn btn-sm" OnClick="btnADD_Click" Text="Add" />
    </div>
  </div>

</div>
&#13;
&#13;
&#13;

然后这是背后的代码:

public void drpCategory_TextChanged(object sender, EventArgs e)
{
    if (drpCategory.Text == "Others")
    {
        drpItem.Visible = false;
        txtitem.Visible = true;
    } 
    else
    {
        byCateg();
        DataBind();
        drpItem.Visible = true;
        txtitem.Visible = false;
    }
}

我的代码有问题吗?

0 个答案:

没有答案