void listele() { SqlDataReader reader; SqlConnection con = new SqlConnection(); con.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["Veritabani"].ConnectionString; DataTable tbl = new DataTable(); SqlCommand cmd = new SqlCommand("select id,tblOgrenciNot.ogrencino ,(CAST(tblOgrenci.ogrenciad AS nvarchar) + ' ' + CAST(tblOgrenci.ogrencisoyad AS nvarchar)) AS adsoyad," + " tblDersler.dersad, ogrencinotu from tblOgrenciNot " + " INNER JOIN tblOgrenci ON tblOgrenciNot.ogrencino=tblOgrenci.ogrencino" + " INNER JOIN tblDersler ON tblOgrenciNot.dersid = tblDersler.dersid order by tblOgrenciNot.ogrencino asc ", con); try { con.Open(); reader = cmd.ExecuteReader(); GridViewnot.DataSource = reader; GridViewnot.DataBind(); reader.Close(); } catch (Exception) { throw; } }
protected void Buttonaktar_Click(object sender, EventArgs e) { HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1254"); HttpContext.Current.Response.Charset = "windows-1254"; Response.ClearContent(); Response.AddHeader("content-disposition", "attachment; filename=öğrenciEklenenNot.xls"); Response.ContentType = "application/excel"; System.IO.StringWriter sw = new System.IO.StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); GridViewnot.RenderControl(htw); Response.Write(sw.ToString()); Response.End(); }