我的 aspx 页面中有一个下拉列表,其值为:
//DropDownlist value: 1--> show notice in one day ago; 2--> 7 days ago;3--> 30 days ago.
<asp:DropDownList ID="DropDownListTime" runat="server">
AutoPostBack="true" >
<asp:ListItem Selected="True"></asp:ListItem>
<asp:ListItem Value="1"> 1 day ago </asp:ListItem>
<asp:ListItem Value="2"> 7 days ago </asp:ListItem>
<asp:ListItem Value="3"> 30 days ago </asp:ListItem>
</asp:DropDownList>
和cs页面中的代码:
protected void Page_Load(object sender, EventArgs e)
{ if (!IsPostBack)
{
BindData();
}
}
public void BindData()
{
string key="";
if (string.IsNullOrEmpty(DropDownListTime.SelectedValue))
{
key = "3";
}
else
{
key = DropDownListTime.SelectedValue.ToString();
}
HyperLink1.NavigateUrl = string.Format("Allnotice.aspx?key={0}",key);
// go to page to show all notices with `1 day`,`7days`,`30 days` ago depend on the `key`
}
public void IndexNotice_Changed(Object sender, EventArgs e)
{
BindData();
}
调试的时候,关键就在我选择的那个选项上。但是在下拉列表中选择一个选项后,我单击超链接,它通过Allnotice.aspx
key="3" 传递到页面。总是而且总是甚至我选择了什么选项。
有关详细信息:我选择7 days ago
---> 调试:key= 2
-> 然后单击超链接 ---> 下一页收到了key=3
.
帮助!!!!
更新:我已经问过这个问题,但没有人可以提供帮助。所以我试着用简单的方式来描述它,如果它是重复的,希望你不要介意。