using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.IO; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { DirectoryInfo di = new DirectoryInfo(Server.MapPath("~")); GridView1.DataSource = di.GetFiles(); GridView1.DataBind(); if (!IsPostBack) { DropDownList1.DataSource = di.GetFiles(); DropDownList1.DataTextField = "Name"; DropDownList1.DataValueField = "Length"; DropDownList1.DataBind(); } var nimed = from f in di.GetFiles() select f.Name.Split('.').First(); DropDownList2.DataSource = nimed; DropDownList2.DataBind(); var nimed2 = from f in di.GetFiles() select new { nimi = f.Name.Split('.').First(), pikkus = f.Name.Split('.')[1] }; GridView2.DataSource = nimed2; GridView2.DataBind(); } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { Label1.Text = DropDownList1.SelectedValue; } }