<%@ Page Language="C#" Debug="true" %>
<script runat="server">
private void Page_Load(object sender, System.EventArgs e) {
string MyFileName;
System.IO.StreamReader ObjectStreamReader = null;
ArrayList FileLines = new ArrayList();
MyFileName = Page.MapPath("Data.txt");
try {
ObjectStreamReader = new System.IO.StreamReader (MyFileName);
while (ObjectStreamReader.Peek() > -1) {
FileLines.Add(ObjectStreamReader.ReadLine());
}
FileLines.Sort();
Label1.Text = "Select a title:";
DropDownList1.DataSource = FileLines;
DropDownList1.DataBind();
} catch (Exception ObjectError) {
Label1.Text = ObjectError.Message;
DropDownList1.Visible = false;
} finally {
if (ObjectStreamReader != null) {
ObjectStreamReader.Close();
}
}
}
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:Label id="Label1" runat="server"></asp:Label>
<asp:DropDownList id="DropDownList1" runat="server"></asp:DropDownList>
</form>
</body>
</html>
|