Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Class1 objektum = new Class1();
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- fillDropdown();
- fillDropdown2();
- }
- }
- private void fillOsztaly()
- {
- string jarat = DropDownList1.SelectedItem.Value;
- string file = "~/jarat/" + jarat + ".txt";
- int i = 1;
- using (StreamReader sr = new StreamReader(Server.MapPath(file)))
- {
- string line;
- while ((line = sr.ReadLine()) != null)
- {
- if (line.Contains("IRÁNY:"))
- {
- if (String.IsNullOrEmpty(objektum.Honnan))
- objektum.Honnan = line.Substring(7).Trim();
- else
- objektum.Hova = line.Substring(7).Trim();
- i = 1;
- }
- else
- {
- if (String.IsNullOrEmpty(objektum.Hova))
- objektum.Indulas.Add(i++ + ". " +line.Trim());
- else
- objektum.Erkezes.Add(i++ + ". " +line.Trim());
- }
- }
- }
- }
- protected void fillDropdown() {
- string[] fill = Directory.GetFiles(Server.MapPath("~/jarat/"),"*.txt");
- for (int x = 0; x < fill.Length; x++) {
- fill[x] = Path.GetFileNameWithoutExtension(fill[x]);
- }
- DropDownList1.DataSource = fill;
- DropDownList1.DataBind();
- }
- protected void fillDropdown2() {
- DropDownList2.Items.Clear();
- fillOsztaly();
- DropDownList2.Items.Add(objektum.Honnan);
- DropDownList2.Items.Add(objektum.Hova);
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- fillOsztaly();
- if (DropDownList2.SelectedIndex == 0)
- {
- GridView1.DataSource = objektum.Indulas;
- }
- else GridView1.DataSource = objektum.Erkezes;
- GridView1.DataBind();
- }
- protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
- {
- fillDropdown2();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement