Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. private string nev;
  2. private List<string> iranyok = new List<string>();
  3. private List<List<string>> jaratok = new List<List<string>>();
  4.  
  5. public string Nev {
  6. get { return nev; }
  7. set { nev = value; }
  8. }
  9. public List<string> Iranyok {
  10. get { return iranyok; }
  11. set { iranyok = value; }
  12. }
  13. public List<List<string>> Jaratok {
  14. get { return jaratok; }
  15. set { jaratok = value; }
  16. }
  17. ----------
  18. using System;
  19. using System.Collections.Generic;
  20. using System.Linq;
  21. using System.Web;
  22. using System.Web.UI;
  23. using System.Web.UI.WebControls;
  24. using System.IO;
  25.  
  26. namespace a7_busz
  27. {
  28. public partial class _default : System.Web.UI.Page
  29. {
  30. private List<jarat> buszok = new List<jarat>();
  31.  
  32. protected void Page_Load(object sender, EventArgs e)
  33. {
  34. string[] files = Directory.GetFiles(Server.MapPath("~/jaratok/"), "*.txt");
  35.  
  36. foreach(string file in files) {
  37. if (!IsPostBack)
  38. DropDownList1.Items.Add(Path.GetFileNameWithoutExtension(file));
  39. jarat j = new jarat();
  40. j.Nev = Path.GetFileNameWithoutExtension(file);
  41. using (StreamReader sr = new StreamReader(file)) {
  42. string line;
  43. while ((line = sr.ReadLine()) != null) {
  44. if (line.Substring(0,1) == "I")
  45. j.Iranyok.Add(line.Substring(7));
  46. else {
  47. if (j.Jaratok.Count < j.Iranyok.Count)
  48. j.Jaratok.Add(new List<string>());
  49. j.Jaratok[j.Jaratok.Count - 1].Add(line);
  50. }
  51. }
  52. }
  53. buszok.Add(j);
  54. }
  55. if (!IsPostBack) resetDrop2();
  56. }
  57.  
  58. private void resetDrop2() {
  59. List<string> iranyok = new List<string>();
  60. foreach (jarat j in buszok)
  61. if (j.Nev == DropDownList1.SelectedValue)
  62. iranyok = j.Iranyok;
  63. DropDownList2.DataSource = iranyok;
  64. DropDownList2.DataBind();
  65. }
  66.  
  67. protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) {
  68. resetDrop2();
  69. }
  70. protected void Button1_Click(object sender, EventArgs e) {
  71. foreach (jarat j in buszok)
  72. if (j.Nev == DropDownList1.SelectedValue)
  73. for (int i = 0; i < j.Iranyok.Count; i++)
  74. if (j.Iranyok[i] == DropDownList2.SelectedValue) {
  75. GridView1.DataSource = j.Jaratok[i].Select(item => new { jaratok = item });
  76. GridView1.DataBind();
  77. }
  78. }
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement