如何使用下拉列表呈现html表? [英] How to render html table using dropdown list?
问题描述
当我从下拉菜单中选择列表项时,我希望能够更改我的html表。
例如,
目前,当页面加载时,html表只呈现当前方法。
Hi,
I would like to be able to change my html table when I select list item from the dropdown menu.
For example,
Currently, when the page loads, the html table only renders current method.
<tbody>
<tr>
<th><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></th>
<th><asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></th>
<th><asp:TextBox ID="TextBox3" runat="server"></asp:TextBox></th>
</tr>
<tr>
<%=current()%>
</tr>
</tbody>
我想构建逻辑,如果我从下拉菜单中选择每周选项,我希望html表格呈现每周()。方法。
我是否需要在current()方法中创建此登录名。如果是这样,我将如何通过下拉事件方法传递
?
当前进度:
I would like to build logic for, If I select weekly option from the dropdown menu, I would like the html table to render the weekly().method.
Would I need to create this login inside the current() method. if so, how would I
pass the dropdown event method?
Current progress:
protected void myListDropDown_Change(object sender, EventArgs e)
{
DropDownList ctrl1 = FindControl("ddlDate") as DropDownList;
if (ctrl1.SelectedValue == "Weekly")
{
string week = weekly();
// not sure how to implement after this stage...???
}
}
<p><asp:DropDownList ID="ddlDate" runat="server" Width="200px" OnSelectedIndexChanged="myListDropDown_Change">
<asp:ListItem Text="Select Timeline" Value=""></asp:ListItem>
<asp:ListItem Text="Weekly" Value=""></asp:ListItem>
<asp:ListItem Text="Monthly" Value=""></asp:ListItem>
</asp:DropDownList></p>
任何进一步的帮助都会非常感谢。非常感谢
Any further help would be very much appreciated. Many thanks
推荐答案
我建议你使用一个方法,通过检查所选的值来呈现正确的内容......毕竟该方法在服务器上运行在下拉菜单的同一页面中...
I would advise you to use a single method that will render the correct content by checking the selected value...After all that method runs on the server in the very same page where the drop-down is...
<table><tbody><tr>
<%=render()%>
</tr></tbody></table>
public string render()
{
swtich(dropdown.SelectedValue)
{
case: 1:
{
}
break;
case: 2:
{
}
break;
}
}
下拉列表的更改方法仅用于页面刷新...
The Change method of drop-down will be used only for page refresh...
这篇关于如何使用下拉列表呈现html表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!