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 <[EMAIL PROTECTED]> wrote:
kya baat hain...waah ustaad waahh
Krunal Chaklasia <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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:
[EMAIL PROTECTED]
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:
[EMAIL PROTECTED]
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]
------------------------ Yahoo! Groups Sponsor --------------------~-->
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/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/