freelanceprogrammers.org Forum Index » ASP
Nirmal : Export Datagrid to text file
Joined: 25 Jan 2005
Posts: 12
Nirmal : Export Datagrid to text file
Sir,
I want to export the Datagrid to textfile in asp.net.
Please help me sir.
---------------------------------
Yahoo! India Matrimony: Find your partner online.
Go to http://yahoo.shaadi.com
[Non-text portions of this message have been removed]
Joined: 01 Sep 2005
Posts: 1
Nirmal : Export Datagrid to text file
Check it out this code,
Database db = DatabaseFactory.CreateDatabase();
DBCommandWrapper selectCommandWrapper =
db.GetStoredProcCommandWrapper("sp_GetLatestArticles");
DataSet ds = db.ExecuteDataSet(selectCommandWrapper);
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();
KRUNAL CHAKLASIA
HCL Technologies.
Nirmal Abraham <mnrajra@...> wrote:
Sir,
I want to export the Datagrid to textfile in asp.net.
Please help me sir.
---------------------------------
Yahoo! India Matrimony: Find your partner online.
Go to http://yahoo.shaadi.com
[Non-text portions of this message have been removed]
Yahoo! Groups Links
---------------------------------
Start your day with Yahoo! - make it your home page
[Non-text portions of this message have been removed]
Joined: 01 Sep 2005
Posts: 1
Nirmal : Export Datagrid to text file
kya baat hain...waah ustaad waahh
Krunal Chaklasia <krunal_aspdotnet@...> wrote:Check it out this code,
Database db = DatabaseFactory.CreateDatabase();
DBCommandWrapper selectCommandWrapper =
db.GetStoredProcCommandWrapper("sp_GetLatestArticles");
DataSet ds = db.ExecuteDataSet(selectCommandWrapper);
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();
KRUNAL CHAKLASIA
HCL Technologies.
Nirmal Abraham <mnrajra@...> wrote:
Sir,
I want to export the Datagrid to textfile in asp.net.
Please help me sir.
---------------------------------
Yahoo! India Matrimony: Find your partner online.
Go to http://yahoo.shaadi.com
[Non-text portions of this message have been removed]
Yahoo! Groups Links
---------------------------------
Start your day with Yahoo! - make it your home page
[Non-text portions of this message have been removed]
---------------------------------
YAHOO! GROUPS LINKS
Visit your group "AspNetAnyQuestionIsOk" on the web.
To unsubscribe from this group, send an email to:
AspNetAnyQuestionIsOk-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
---------------------------------
Start your day with Yahoo! - make it your home page
[Non-text portions of this message have been removed]
Joined: 25 Jan 2005
Posts: 12
Nirmal : Export Datagrid to text file
Sir,
I am Having the Datagrid like this in ASP.NET(VB.NET).
How can I Export to Text.
Please Help me sir.
-------------------------------------------------------------
Private Sub BindData()
Dim da As New SqlDataAdapter("RptDate_Cou_in", Con)
da.SelectCommand.CommandType = CommandType.StoredProcedure
With da.SelectCommand.Parameters
.Add("@xDateFrom", txtFrom.Text)
.Add("@xDateTo", txtTo.Text)
.Add("@xYear", "05")
End With
ds = New DataSet
da.Fill(ds, "RptDate_Cou_in")
Dim curCat As String
Dim prevCat As String
Dim i As Integer = 0
Do While i <= ds.Tables(0).Rows.Count - 1
curCat = ds.Tables(0).Rows(i).Item("CourierName")
If curCat <> prevCat Then
prevCat = curCat
Dim shRow As DataRow = ds.Tables(0).NewRow
shRow("Doc_no") = ds.Tables(0).Rows(i).Item(0)
shRow("Consignee") = "subHead"
ds.Tables(0).Rows.InsertAt(shRow, i)
i += 1
End If
i += 1
Loop
DgrdAttn.DataSource = ds.Tables("RptDate_Cou_in")
DgrdAttn.DataBind()
da.Dispose()
Con.Close()
End Sub
Private Sub DgrdAttn_ItemDataBound(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
Handles DgrdAttn.ItemDataBound
Select Case e.Item.ItemType
Case ListItemType.AlternatingItem, ListItemType.Item
If e.Item.Cells(1).Text.Equals("subHead") Then
e.Item.Cells(0).Attributes.Add("align", "Center")
e.Item.Cells(0).ColumnSpan = 6
e.Item.Cells(0).Font.Bold = False
e.Item.Cells(0).BackColor = Color.MistyRose
e.Item.Cells.RemoveAt(5)
e.Item.Cells.RemoveAt(4)
e.Item.Cells.RemoveAt(3)
e.Item.Cells.RemoveAt(2)
e.Item.Cells.RemoveAt(1)
End If
End Select
End Sub
Private Sub Butt1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Butt1.Click
BindData()
End Sub
Jayesh Bhatia <jayesh_bhatia1@...> wrote:
kya baat hain...waah ustaad waahh
Krunal Chaklasia <krunal_aspdotnet@...> wrote:Check it out this code,
Database db = DatabaseFactory.CreateDatabase();
DBCommandWrapper selectCommandWrapper =
db.GetStoredProcCommandWrapper("sp_GetLatestArticles");
DataSet ds = db.ExecuteDataSet(selectCommandWrapper);
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();
KRUNAL CHAKLASIA
HCL Technologies.
Nirmal Abraham <mnrajra@...> wrote:
Sir,
I want to export the Datagrid to textfile in asp.net.
Please help me sir.
---------------------------------
Yahoo! India Matrimony: Find your partner online.
Go to http://yahoo.shaadi.com
[Non-text portions of this message have been removed]
Yahoo! Groups Links
---------------------------------
Start your day with Yahoo! - make it your home page
[Non-text portions of this message have been removed]
---------------------------------
YAHOO! GROUPS LINKS
Visit your group "AspNetAnyQuestionIsOk" on the web.
To unsubscribe from this group, send an email to:
AspNetAnyQuestionIsOk-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
---------------------------------
Start your day with Yahoo! - make it your home page
[Non-text portions of this message have been removed]
SPONSORED LINKS
Basic programming language Computer programming languages Programming languages
Java programming language The history of computer programming language
---------------------------------
YAHOO! GROUPS LINKS
Visit your group "AspNetAnyQuestionIsOk" on the web.
To unsubscribe from this group, send an email to:
AspNetAnyQuestionIsOk-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
---------------------------------
Yahoo! India Matrimony: Find your partner online.
Go to http://yahoo.shaadi.com
[Non-text portions of this message have been removed]
Joined: 25 Jan 2005
Posts: 12
Nirmal : Export Datagrid to text file
Sir,
I am Having the Datagrid like this in ASP.NET(VB.NET).
How can I Export to Text.
Please Help me sir.
--------------------------------------------------------------------------------
-------------
Private Sub BindData()
Dim da As New SqlDataAdapter("RptDate_Cou_in", Con)
da.SelectCommand.CommandType = CommandType.StoredProcedure
With da.SelectCommand.Parameters
.Add("@xDateFrom", txtFrom.Text)
.Add("@xDateTo", txtTo.Text)
.Add("@xYear", "05")
End With
ds = New DataSet
da.Fill(ds, "RptDate_Cou_in")
Dim curCat As String
Dim prevCat As String
Dim i As Integer = 0
Do While i <= ds.Tables(0).Rows.Count - 1
curCat = ds.Tables(0).Rows(i).Item("CourierName")
If curCat <> prevCat Then
prevCat = curCat
Dim shRow As DataRow = ds.Tables(0).NewRow
shRow("Doc_no") = ds.Tables(0).Rows(i).Item(0)
shRow("Consignee") = "subHead"
ds.Tables(0).Rows.InsertAt(shRow, i)
i += 1
End If
i += 1
Loop
DgrdAttn.DataSource = ds.Tables("RptDate_Cou_in")
DgrdAttn.DataBind()
da.Dispose()
Con.Close()
End Sub
Private Sub DgrdAttn_ItemDataBound(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
Handles DgrdAttn.ItemDataBound
Select Case e.Item.ItemType
Case ListItemType.AlternatingItem, ListItemType.Item
If e.Item.Cells(1).Text.Equals("subHead") Then
e.Item.Cells(0).Attributes.Add("align", "Center")
e.Item.Cells(0).ColumnSpan = 6
e.Item.Cells(0).Font.Bold = False
e.Item.Cells(0).BackColor = Color.MistyRose
e.Item.Cells.RemoveAt(5)
e.Item.Cells.RemoveAt(4)
e.Item.Cells.RemoveAt(3)
e.Item.Cells.RemoveAt(2)
e.Item.Cells.RemoveAt(1)
End If
End Select
End Sub
Private Sub Butt1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Butt1.Click
BindData()
End Sub
Krunal Chaklasia <krunal_aspdotnet@...> wrote:
Check it out this code,
Database db = DatabaseFactory.CreateDatabase();
DBCommandWrapper selectCommandWrapper =
db.GetStoredProcCommandWrapper("sp_GetLatestArticles");
DataSet ds = db.ExecuteDataSet(selectCommandWrapper);
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();
KRUNAL CHAKLASIA
HCL Technologies.
Nirmal Abraham <mnrajra@...> wrote:
Sir,
I want to export the Datagrid to textfile in asp.net.
Please help me sir.
---------------------------------
Yahoo! India Matrimony: Find your partner online.
Go to http://yahoo.shaadi.com
[Non-text portions of this message have been removed]
Yahoo! Groups Links
---------------------------------
Start your day with Yahoo! - make it your home page
[Non-text portions of this message have been removed]
---------------------------------
YAHOO! GROUPS LINKS
Visit your group "AspNetAnyQuestionIsOk" on the web.
To unsubscribe from this group, send an email to:
AspNetAnyQuestionIsOk-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
---------------------------------
Yahoo! India Matrimony: Find your partner online.
Go to http://yahoo.shaadi.com
[Non-text portions of this message have been removed]
Joined: 05 Sep 2005
Posts: 3
Nirmal : Export Datagrid to text file
Hi,
//////////////////// If u want to import Grid in text File
////////////////////////////////
SqlConnection sqlConnection = new SqlConnection(connString);
sqlConnection.Open();
SqlDataAdapter ada = new SqlDataAdapter("SELECT Lic_Id, Lic_MailState,
(Lic_LiCFNm + ` ` + Lic_LicLNm) As LicName FROM
Tbl_LicenseeAdmin",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();
////////////////////////////////////////////////////////////////////////////////
//////////////////
////////////////////////// In word File
////////////////////////////////////////////////////
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=FileName.doc");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.word";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
myDataGrid.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
////////////////////////////////////////////////////////////////////////////////
///////////////
Regards
Krishan Kant
Nirmal Abraham <mnrajra@...> wrote:
Sir,
I am Having the Datagrid like this in ASP.NET(VB.NET).
How can I Export to Text.
Please Help me sir.
--------------------------------------------------------------------------------
-------------
Private Sub BindData()
Dim da As New SqlDataAdapter("RptDate_Cou_in", Con)
da.SelectCommand.CommandType = CommandType.StoredProcedure
With da.SelectCommand.Parameters
.Add("@xDateFrom", txtFrom.Text)
.Add("@xDateTo", txtTo.Text)
.Add("@xYear", "05")
End With
ds = New DataSet
da.Fill(ds, "RptDate_Cou_in")
Dim curCat As String
Dim prevCat As String
Dim i As Integer = 0
Do While i <= ds.Tables(0).Rows.Count - 1
curCat = ds.Tables(0).Rows(i).Item("CourierName")
If curCat <> prevCat Then
prevCat = curCat
Dim shRow As DataRow = ds.Tables(0).NewRow
shRow("Doc_no") = ds.Tables(0).Rows(i).Item(0)
shRow("Consignee") = "subHead"
ds.Tables(0).Rows.InsertAt(shRow, i)
i += 1
End If
i += 1
Loop
DgrdAttn.DataSource = ds.Tables("RptDate_Cou_in")
DgrdAttn.DataBind()
da.Dispose()
Con.Close()
End Sub
Private Sub DgrdAttn_ItemDataBound(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
Handles DgrdAttn.ItemDataBound
Select Case e.Item.ItemType
Case ListItemType.AlternatingItem, ListItemType.Item
If e.Item.Cells(1).Text.Equals("subHead") Then
e.Item.Cells(0).Attributes.Add("align", "Center")
e.Item.Cells(0).ColumnSpan = 6
e.Item.Cells(0).Font.Bold = False
e.Item.Cells(0).BackColor = Color.MistyRose
e.Item.Cells.RemoveAt(5)
e.Item.Cells.RemoveAt(4)
e.Item.Cells.RemoveAt(3)
e.Item.Cells.RemoveAt(2)
e.Item.Cells.RemoveAt(1)
End If
End Select
End Sub
Private Sub Butt1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Butt1.Click
BindData()
End Sub
Krunal Chaklasia <krunal_aspdotnet@...> wrote:
Check it out this code,
Database db = DatabaseFactory.CreateDatabase();
DBCommandWrapper selectCommandWrapper =
db.GetStoredProcCommandWrapper("sp_GetLatestArticles");
DataSet ds = db.ExecuteDataSet(selectCommandWrapper);
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();
KRUNAL CHAKLASIA
HCL Technologies.
Nirmal Abraham <mnrajra@...> wrote:
Sir,
I want to export the Datagrid to textfile in asp.net.
Please help me sir.
---------------------------------
Yahoo! India Matrimony: Find your partner online.
Go to http://yahoo.shaadi.com
[Non-text portions of this message have been removed]
Yahoo! Groups Links
---------------------------------
Start your day with Yahoo! - make it your home page
[Non-text portions of this message have been removed]
---------------------------------
YAHOO! GROUPS LINKS
Visit your group "AspNetAnyQuestionIsOk" on the web.
To unsubscribe from this group, send an email to:
AspNetAnyQuestionIsOk-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
---------------------------------
Yahoo! India Matrimony: Find your partner online.
Go to http://yahoo.shaadi.com
[Non-text portions of this message have been removed]
SPONSORED LINKS
Basic programming language Computer programming languages Programming languages
Java programming language The history of computer programming language
---------------------------------
YAHOO! GROUPS LINKS
Visit your group "AspNetAnyQuestionIsOk" on the web.
To unsubscribe from this group, send an email to:
AspNetAnyQuestionIsOk-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
--------------------------------------------------------------------
Krishan Kant Chamoli Office: +91-172-2653886
AutherGen Technology (P) Ltd., Fax: +91-172-5018485
24/3, Industrial Area, Phase - 2, Mobile: 9888263726
Chandigarh. INDIA. Pin - 160002. Email: kkchamoli@...
--------------------------------------------------------------------
Send instant messages to your online friends http://uk.messenger.yahoo.com
[Non-text portions of this message have been removed]
Joined: 25 Jan 2005
Posts: 12
Nirmal : Export Datagrid to text file
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>06Imp
ort<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]
Joined: 25 Jan 2005
Posts: 12
Nirmal : Export Datagrid to text file
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>06Imp
ort<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.
----------------------------------------------------------
krishan kant chamoli <kk_chamoli@...> wrote:Hi,
//////////////////// If u want to import Grid in text File
////////////////////////////////
SqlConnection sqlConnection = new SqlConnection(connString);
sqlConnection.Open();
SqlDataAdapter ada = new SqlDataAdapter("SELECT Lic_Id, Lic_MailState,
(Lic_LiCFNm + ` ` + Lic_LicLNm) As LicName FROM
Tbl_LicenseeAdmin",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();
////////////////////////////////////////////////////////////////////////////////
//////////////////
////////////////////////// In word File
////////////////////////////////////////////////////
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=FileName.doc");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.word";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
myDataGrid.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
////////////////////////////////////////////////////////////////////////////////
///////////////
Regards
Krishan Kant
Nirmal Abraham <mnrajra@...> wrote:
Sir,
I am Having the Datagrid like this in ASP.NET(VB.NET).
How can I Export to Text.
Please Help me sir.
--------------------------------------------------------------------------------
-------------
Private Sub BindData()
Dim da As New SqlDataAdapter("RptDate_Cou_in", Con)
da.SelectCommand.CommandType = CommandType.StoredProcedure
With da.SelectCommand.Parameters
.Add("@xDateFrom", txtFrom.Text)
.Add("@xDateTo", txtTo.Text)
.Add("@xYear", "05")
End With
ds = New DataSet
da.Fill(ds, "RptDate_Cou_in")
Dim curCat As String
Dim prevCat As String
Dim i As Integer = 0
Do While i <= ds.Tables(0).Rows.Count - 1
curCat = ds.Tables(0).Rows(i).Item("CourierName")
If curCat <> prevCat Then
prevCat = curCat
Dim shRow As DataRow = ds.Tables(0).NewRow
shRow("Doc_no") = ds.Tables(0).Rows(i).Item(0)
shRow("Consignee") = "subHead"
ds.Tables(0).Rows.InsertAt(shRow, i)
i += 1
End If
i += 1
Loop
DgrdAttn.DataSource = ds.Tables("RptDate_Cou_in")
DgrdAttn.DataBind()
da.Dispose()
Con.Close()
End Sub
Private Sub DgrdAttn_ItemDataBound(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
Handles DgrdAttn.ItemDataBound
Select Case e.Item.ItemType
Case ListItemType.AlternatingItem, ListItemType.Item
If e.Item.Cells(1).Text.Equals("subHead") Then
e.Item.Cells(0).Attributes.Add("align", "Center")
e.Item.Cells(0).ColumnSpan = 6
e.Item.Cells(0).Font.Bold = False
e.Item.Cells(0).BackColor = Color.MistyRose
e.Item.Cells.RemoveAt(5)
e.Item.Cells.RemoveAt(4)
e.Item.Cells.RemoveAt(3)
e.Item.Cells.RemoveAt(2)
e.Item.Cells.RemoveAt(1)
End If
End Select
End Sub
Private Sub Butt1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Butt1.Click
BindData()
End Sub
Krunal Chaklasia <krunal_aspdotnet@...> wrote:
Check it out this code,
Database db = DatabaseFactory.CreateDatabase();
DBCommandWrapper selectCommandWrapper =
db.GetStoredProcCommandWrapper("sp_GetLatestArticles");
DataSet ds = db.ExecuteDataSet(selectCommandWrapper);
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();
KRUNAL CHAKLASIA
HCL Technologies.
Nirmal Abraham <mnrajra@...> wrote:
Sir,
I want to export the Datagrid to textfile in asp.net.
Please help me sir.
---------------------------------
Yahoo! India Matrimony: Find your partner online.
Go to http://yahoo.shaadi.com
[Non-text portions of this message have been removed]
Yahoo! Groups Links
---------------------------------
Start your day with Yahoo! - make it your home page
[Non-text portions of this message have been removed]
---------------------------------
YAHOO! GROUPS LINKS
Visit your group "AspNetAnyQuestionIsOk" on the web.
To unsubscribe from this group, send an email to:
AspNetAnyQuestionIsOk-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
---------------------------------
Yahoo! India Matrimony: Find your partner online.
Go to http://yahoo.shaadi.com
[Non-text portions of this message have been removed]
SPONSORED LINKS
Basic programming language Computer programming languages Programming languages
Java programming language The history of computer programming language
---------------------------------
YAHOO! GROUPS LINKS
Visit your group "AspNetAnyQuestionIsOk" on the web.
To unsubscribe from this group, send an email to:
AspNetAnyQuestionIsOk-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
--------------------------------------------------------------------
Krishan Kant Chamoli Office: +91-172-2653886
AutherGen Technology (P) Ltd., Fax: +91-172-5018485
24/3, Industrial Area, Phase - 2, Mobile: 9888263726
Chandigarh. INDIA. Pin - 160002. Email: kkchamoli@...
--------------------------------------------------------------------
Send instant messages to your online friends http://uk.messenger.yahoo.com
[Non-text portions of this message have been removed]
SPONSORED LINKS
Basic programming language Computer programming languages Programming languages
Java programming language The history of computer programming language
---------------------------------
YAHOO! GROUPS LINKS
Visit your group "AspNetAnyQuestionIsOk" on the web.
To unsubscribe from this group, send an email to:
AspNetAnyQuestionIsOk-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
---------------------------------
Yahoo! India Matrimony: Find your partner online.
[Non-text portions of this message have been removed]
All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help
China Wholesale - Electronics Products
Character Studio - Tutorials and Help







