Alexey_didu
New Member
I am using this piece of code at the moment to download the errors stored in columns 'data' and 'data2' residing in the fildemo table in sql database.\[code\] protected void helloGridView_SelectedIndexChanged(object sender, EventArgs e) { String connectionString = DAO.GetConnectionString(); String sqlQuery = String.Empty; using (SqlConnection con = new SqlConnection(connectionString)) { con.Open(); sqlQuery = "select data,data2 from filedemo where id=@id"; SqlCommand cmd = new SqlCommand(sqlQuery, con); cmd.Parameters.AddWithValue("id", surgicalGridView.SelectedRow.Cells[1].Text); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { HttpContext.Current.Response.ClearContent(); HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + dr["name"].ToString() + ".xls"); HttpContext.Current.Response.ContentType = "application/excel"; Response.Charset = ""; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Write(dr["data"] + "\t"); Response.Write(dr["data2"] + "\t"); Response.End(); } } }\[/code\]I will want to pull out errors from the different rows with the same Id and store them in separate rows in the excel file. How do I go about doing it?