I have given the Coding you have given.
private void Button3_Click(object sender, System.EventArgs e)
{
SqlConnection sqlConnection = new
SqlConnection("database=Admin;server=sj2005;uid=sa;pwd=;");
sqlConnection.Open();
SqlDataAdapter ada = new SqlDataAdapter("SELECT deptcode,deptname from
cou_dept",sqlConnection);
ds = new DataSet();
ada.Fill(ds);
StringBuilder str = new StringBuilder();
for(int i=0;i<=ds.Tables[0].Rows.Count - 1; i++)
{
for(int j=0;j<=ds.Tables[0].Columns.Count - 1; j++)
{
str.Append(ds.Tables[0].Rows[i][j].ToString());
}
str.Append("<BR>");
}
Response.Clear();
Response.AddHeader("content-disposition",
"attachment;filename=FileName.txt");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.text";
System.IO.StringWriter stringWrite = new
System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite =
new HtmlTextWriter(stringWrite);
Response.Write(str.ToString());
Response.End();
}
But my Output is without the heading and without order like this :
01Information
Technology<BR>02Maritimes<BR>03Accounts<BR>04Administration<BR>05Export<BR>06Import<BR>07HRM<BR>08TUDA<BR>09TVPO<BR>10MD<BR>12TUMO<BR>13Marketers<BR>14Paper
&
Board<BR>15TUDF<BR>16Transport<BR>17Chartering<BR>18Engineering<BR>19Customs<BR>20Fumigation<BR>21Container
Freight
System<BR>22Timber<BR>23TUDC<BR>24TUZT<BR>25GGMF<BR>26UCMAS<BR>27SFD<BR>28GM.Sec<BR>29TUMF<BR>30TUDP<BR>31DGHR<BR>32TUDX<BR>
Please Help me sir.
---------------------------------
Yahoo! India Matrimony: Find your partner online.
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/saFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/