我是 asp.net 和 c# 的新手。我正在尝试设置下拉列表框中的文本以显示当前页面标题,但我无法让它工作。有人可以根据下面的代码建议如何做吗?谢谢!
if (!Page.IsPostBack)
{
string path = @"C:\Websites\TaxMapCS";
DirectoryInfo di = new DirectoryInfo(path);
FileSystemInfo[] fi = di.GetFiles("*.aspx");
var result = string.Join(",", fi.OrderByDescending(f => f.CreationTime).Select(i => i.ToString()).ToArray());
DropDownList1.DataSource = result.Replace(".aspx", "").Split(',');
DropDownList1.DataBind();
DropDownList1.Items.Insert(0, new ListItem("Select Edition", ""));
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Response.Redirect(DropDownList1.SelectedItem.Value + ".aspx");
}