using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace veeb1 { public partial class leht3 : System.Web.UI.Page { string failikoht; protected void Page_Load(object sender, EventArgs e) { failikoht = Server.MapPath("~/App_Data/nimedpikkused.txt"); var lapsed2=File.ReadAllLines(failikoht).Select(rida => rida.Split(',')). Select(m => new { eesnimi = m[0], pikkus = m[1] }). Where(laps => laps.eesnimi.StartsWith(TextBox1.Text)). OrderByDescending(laps => laps.pikkus); var laps1 = new { eesnimi = "Juku", pikkus = "135" }; var laps2 = new { eesnimi= "Mati", pikkus= "145" } ; List lapsed = new List(); lapsed.Add(laps1); lapsed.Add(laps2); // var lapsed = { laps1, laps2 }; GridView1.DataSource = lapsed2; GridView1.DataBind(); } protected void Button1_Click(object sender, EventArgs e) { if (TextBox2.Text.Length > 0) { File.AppendAllText(failikoht, TextBox2.Text + "," + TextBox3.Text + "\r\n"); TextBox2.Text = ""; TextBox3.Text = ""; } } } }