Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private string nev;
- private List<string> iranyok = new List<string>();
- private List<List<string>> jaratok = new List<List<string>>();
- public string Nev {
- get { return nev; }
- set { nev = value; }
- }
- public List<string> Iranyok {
- get { return iranyok; }
- set { iranyok = value; }
- }
- public List<List<string>> Jaratok {
- get { return jaratok; }
- set { jaratok = value; }
- }
- ----------
- 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 a7_busz
- {
- public partial class _default : System.Web.UI.Page
- {
- private List<jarat> buszok = new List<jarat>();
- protected void Page_Load(object sender, EventArgs e)
- {
- string[] files = Directory.GetFiles(Server.MapPath("~/jaratok/"), "*.txt");
- foreach(string file in files) {
- if (!IsPostBack)
- DropDownList1.Items.Add(Path.GetFileNameWithoutExtension(file));
- jarat j = new jarat();
- j.Nev = Path.GetFileNameWithoutExtension(file);
- using (StreamReader sr = new StreamReader(file)) {
- string line;
- while ((line = sr.ReadLine()) != null) {
- if (line.Substring(0,1) == "I")
- j.Iranyok.Add(line.Substring(7));
- else {
- if (j.Jaratok.Count < j.Iranyok.Count)
- j.Jaratok.Add(new List<string>());
- j.Jaratok[j.Jaratok.Count - 1].Add(line);
- }
- }
- }
- buszok.Add(j);
- }
- if (!IsPostBack) resetDrop2();
- }
- private void resetDrop2() {
- List<string> iranyok = new List<string>();
- foreach (jarat j in buszok)
- if (j.Nev == DropDownList1.SelectedValue)
- iranyok = j.Iranyok;
- DropDownList2.DataSource = iranyok;
- DropDownList2.DataBind();
- }
- protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) {
- resetDrop2();
- }
- protected void Button1_Click(object sender, EventArgs e) {
- foreach (jarat j in buszok)
- if (j.Nev == DropDownList1.SelectedValue)
- for (int i = 0; i < j.Iranyok.Count; i++)
- if (j.Iranyok[i] == DropDownList2.SelectedValue) {
- GridView1.DataSource = j.Jaratok[i].Select(item => new { jaratok = item });
- GridView1.DataBind();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement