Click here to Skip to main content
15,888,968 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want a sample C# coding to export the data from grid view to notepad in asp.net....
Posted

on the click event u can write this code..


ExportToExcelML exporter = new ExportToExcelML(dgvNetPosition);
exporter.SheetMaxRows = ExcelMaxRows._65536;
exporter.ExportVisualSettings = true;
exporter.RunExport(sfdSaveFileDialog.FileName);



hope it works..
 
Share this answer
 
v3
To export data in notepad you need to crate .txt file.

if your datagrid have more than one column you need to provide the seperater for columns such as comma(CSV) or Tabs.

steps
// create a writer and open the file
  TextWriter tw = new StreamWriter("date.txt");
// write a data of dg to the file
for(int i=0;i<dg.rowcount;i++)>
{
string line="";
for(int j=0;j<dg.columncount;j++)>
{
line=line+ "your seperator for columns" +dg.rows[i].cells[j].value.tostring();
}
 tw.WriteLine(line);

}

//close writer

tw.close();
 
Share this answer
 
v3
Comments
Monjurul Habib 2-Jun-11 15:32pm    
Edited: code block.
Member 11474887 16-Jul-15 6:55am    
here value means what?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900