Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.IO;
- namespace A14
- {
- public partial class Program : System.Web.UI.Page
- {
- string targetDirectory;
- List<Klasz> klasa = new List<Klasz>();
- public void FillDatum() {
- String[] Files = Directory.GetFiles(targetDirectory, "*.txt");
- for (int x = 0; x < Files.Length; x++)
- {
- Files[x] = Path.GetFileNameWithoutExtension(Files[x]);
- DropDownList1.DataSource = Files;
- DropDownList1.DataBind();
- }
- }
- public void FillOsztaly()
- {
- using (StreamReader file = new StreamReader(targetDirectory + DropDownList1.SelectedItem + ".txt"))
- {
- string line;
- while ((line = file.ReadLine()) != null)
- {
- Klasz obj = new Klasz();
- string[] lineArray = line.Split('|').Select(item => item.Trim()).ToArray();
- obj.Ido = lineArray[0];
- obj.Cim = lineArray[1];
- obj.Tipus = lineArray[2];
- obj.Kep = lineArray[3];
- klasa.Add(obj);
- }
- }
- }
- public void FillDD2()
- {
- List<string> DDTIpus = new List<string>();
- using (StreamReader file = new StreamReader(targetDirectory + DropDownList1.SelectedItem + ".txt"))
- {
- string line;
- while ((line = file.ReadLine()) != null)
- {
- Klasz obj = new Klasz();
- string[] lineArray = line.Split('|').Select(item => item.Trim()).ToArray();
- obj.Tipus = lineArray[2];
- DDTIpus.Add(obj.Tipus);
- }
- }
- DropDownList2.DataSource = DDTIpus.Distinct();
- DropDownList2.DataBind();
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- targetDirectory = Server.MapPath("~/Text/");
- if (!IsPostBack)
- {
- FillDatum();
- FillDD2();
- }
- }
- protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
- {
- FillDD2();
- }
- protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
- {
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- List<Klasz> eredmeny = klasa;
- if (DropDownList1.SelectedIndex > -1)
- {
- FillOsztaly();
- if (DropDownList2.SelectedIndex > -1)
- {
- eredmeny = eredmeny.FindAll(i => i.Tipus.Contains(DropDownList2.SelectedItem.ToString()));
- }
- }
- GridView1.DataSource = eredmeny;
- GridView1.DataBind();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement