0

I got a requirement like taking input from the user through text box to fill grid whenever a dropdown list item "custom" is selected. 仅当用户从下拉列表中选择“自定义”项目时,文本框“fromdate”到“Todate”才需要出现在屏幕上。请告诉我如何在 asp.net 4.0(Visual Studio 2010)中沿网格隐藏这些文本框

4

2 回答 2

1

你为什么不直接去做呢,你已经有了这个想法......

HTML:

<asp:Panel ID="pnl" runat="server" Visible="false">
    <p>Your TextBoxes below...</p>
</asp:Panel>

<asp:DropDownList ID="ddl" runat="server" AutoPostBack="true" 
        onselectedindexchanged="ddl_SelectedIndexChanged">
    <asp:ListItem Value="0" Text="--Select--"></asp:ListItem>
    <asp:ListItem Value="1" Text="Custom"></asp:ListItem>
</asp:DropDownList>

代码背后:

protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
{
    if (ddl.SelectedItem.Text.Equals("Custom"))
        pnl.Visible = true;
    else
        pnl.Visible = false;
}
于 2013-07-23T12:09:45.057 回答
0

我需要将文本框放在 asp.net 的面板中,

<table><tr><td>
    <asp:Label ID="Label1" runat="server" Text="Fromdate:"></asp:Label>
    <asp:TextBox ID="fromdatetxt" runat="server" Height="21px" Width="103px" ></asp:TextBox></td>
           <td>
               <asp:Label ID="Label2" runat="server" Text="Todate:"></asp:Label>
               <asp:TextBox ID="todatetxt" runat="server" Height="21px" Width="105px" ></asp:TextBox></td></tr></table>
</asp:Panel>

并在类文件中编写代码:

protected void atddroplist_SelectedIndexChanged(object sender, EventArgs e)
        {
if (atddroplist.SelectedIndex == 5)
            {

                    datePanel.Visible = true;
}
于 2013-07-23T11:51:33.290 回答