Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 GridView values to Notepad problem

Author  Topic 

krasnokojiy
Starting Member

18 Posts

Posted - 2008-02-25 : 10:28:27
i've a problem with this code:

protected void LinkButton1_Click(object sender, EventArgs e)
{
TextSave();
}
protected void TextSave()
{
StringBuilder sb = new StringBuilder();

foreach (DataControlField cell in gv.Columns)
{
sb.Append(cell.HeaderText + " ");
}
sb.Append(Environment.NewLine);
foreach (GridViewRow gvr in gv.Rows)
{
for (int i = 0; i < gv.Columns.Count; i++)
{
if (gvr.Cells[i].Text == " " || gvr.Cells[i].Text == "")
sb.Append(" - ");
else
sb.Append(gvr.Cells[i].Text + " ");
}

sb.Append(Environment.NewLine);
}

Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=Products.txt");
Response.ContentType = "application/vnd.text";
Response.Write(sb.ToString());
Response.End();
}

i want to take gridview values and insert into a text file but
when i click the LinkButton ,
i take an emty notepad file ,

i havent solved this problem for hours please help



MC

mahesh_bote
Constraint Violating Yak Guru

298 Posts

Posted - 2008-02-27 : 04:07:10
try this link ...

[url]http://www.dotnetspider.com/namespace/ShowClass.aspx?ClassId=48[/url]

Thanks,

Mahesh
Go to Top of Page
   

- Advertisement -