Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
B

basumca

@basumca
About
Posts
2
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Export data to datagerid
    B basumca

    public string Convert(DataTable oDataTable, string directoryPath, string fileName) { string fullpath = ""; if (directoryPath.Substring(directoryPath.Length - 1,1) == @"\" ||directoryPath.Substring(directoryPath.Length - 1,1) == "/") { fullpath = directoryPath + fileName; } else { fullpath = directoryPath + @"\" + fileName; } StreamWriter SW; SW=File.CreateText(fullpath); StringBuilder oStringBuilder = new StringBuilder(); /******************************************************************* * Start, Creating column header * *****************************************************************/ foreach(DataColumn oDataColumn in oDataTable.Columns) { oStringBuilder.Append(oDataColumn.ColumnName + ","); } SW.WriteLine(oStringBuilder.ToString().Substring(0,oStringBuilder.ToString().Length - 1)); oStringBuilder.Length = 0; /******************************************************************* * End, Creating column header * *****************************************************************/ /******************************************************************* * Start, Creating rows * *****************************************************************/ foreach(DataRow oDataRow in oDataTable.Rows) { foreach(DataColumn oDataColumn in oDataTable.Columns) { oStringBuilder.Append(oDataRow[oDataColumn.ColumnName] + ","); } SW.WriteLine(oStringBuilder.ToString().Substring(0,oStringBuilder.ToString().Length - 1)); oStringBuilder.Length = 0; } /******************************************************************* * End, Creating rows * *****************************************************************/ SW.Close(); return fullpath; } write the above code in a class file. and write the below code in your button click event string fileName = System.Guid.NewGuid().ToString().Replace("-","") + ".xls"; (new BLC.CSVConvertor()).Convert(Generatexlsheet() ,Server.MapPath("."),fileName); Response.Redirect(fileName); end of button click event //below is the code for Generatexlsheet : private DataTable Generatexlsheet() { String dbstr = BLC.Class1.Constring(); SqlConnection objconn = new SqlConnection(dbstr); objconn.Open(); // SqlDataReader sqldr = null; // // // SqlCommand cmd = new SqlCommand("select * from employees",objconn

    C# help

  • Back link
    B basumca

    I have a "Back" link in aspx page. If clicked on this link it go to previouspage. For this I wrote back It is working fine. But I also Have a continue button which inserts data into db when clicked on it. So If i go back and click on continue new record is inserte for the same member i don't want that to happen. I want to maintain state persistence. how can I do this. Can Anybody help me Thanx in Advance chanti

    C# database help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups