Пример #1
0
    protected void Buttontmlist_Click(object sender, EventArgs e)
    {
        SqlDataReader reader;
        SqlConnection con = new SqlConnection();

        con.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["Veritabani"].ConnectionString;
        DataTable  tbl     = new DataTable();
        string     bolum   = DropDownListblm.SelectedValue.ToString().Split('-')[0].ToString();
        string     fakulte = DropDownListfklt.SelectedValue.ToString().Split('-')[0].ToString();
        string     sinif   = DropDownListsnf.SelectedValue.ToString().Split('-')[0].ToString();
        SqlCommand cmd     = new SqlCommand("select tblOgrenci.ogrencino as 'ÖĞRENCİ NO',CAST(tblOgrenci.ogrenciad AS nvarchar) + ' ' + CAST(tblOgrenci.ogrencisoyad AS nvarchar) as 'AD SOYAD',"
                                            + " tblSinif.sinifad as 'SINIF', tblBolum.bolumad as 'BÖLÜM', tblFakulte.fakultead as 'FAKÜLTE',"
                                            + " tblDersler.dersad as 'DERS', tblOgrenciNot.ogrencinotu as 'NOT' from tblOgrenci "
                                            + " INNER JOIN tblSinif ON tblOgrenci.sinifid = tblSinif.sinifid"
                                            + " INNER JOIN tblBolum ON tblOgrenci.bolumid = tblBolum.bolumid"
                                            + " INNER JOIN tblFakulte ON tblBolum.fakulteid = tblFakulte.fakulteid"
                                            + " INNER JOIN tblOgrenciNot ON tblOgrenci.ogrencino = tblOgrenciNot.ogrencino"
                                            + " INNER JOIN tblDersler ON tblOgrenciNot.dersid = tblDersler.dersid order by tblOgrenci.ogrencino ", con);

        try
        {
            con.Open();
            reader = cmd.ExecuteReader();
            GridViewliste.DataSource = reader;
            GridViewliste.DataBind();
            reader.Close();
        }
        catch (Exception)
        {
            throw;
        }
    }
Пример #2
0
    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=öğrenciListesi.xls");
        Response.ContentType = "application/excel";
        System.IO.StringWriter sw  = new System.IO.StringWriter();
        HtmlTextWriter         htw = new HtmlTextWriter(sw);

        GridViewliste.RenderControl(htw);
        Response.Write(sw.ToString());
        Response.End();
    }