• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 406
  • Last Modified:

asp.net, c#, <list> Consume

I have attached codes in wcf, and everything working fine.
I can bind the wcf servies by using the following codes(Test: GridView):
However, if I don't have anymore GridView, and I want to write those data
e.g. onto text file like response.write showdata + chr(13)

How can I do that?

protected void Page_Load(object sender, EventArgs e)
            InsuranceServices.DataLibs datalibs = new Insurance.InsuranceServices.DataLibs();
            datalibs.SessionString = "kudm0aab5kdn3r45mdlpfs2t1";          
            Test.DataSource = objService.GetInventoryListInflatable(datalibs);
  • 2
1 Solution
Miguel OzSoftware EngineerCommented:
Let me know which alternative you are after:
- Save as xml file (Check: http://stackoverflow.com/questions/1212742/xml-serialize-generic-list-of-serializable-objects)
The advantage is that you can convert your text file back to List.

- Save as text file (Is this a csv representation of DataLibs class?)
solution1368Author Commented:
basically, I just need to get return value so I can import text file. Behind  the scene,
i have itextsharp and it is very complex and I don't want to explain there.
so I can't use your alternative way(link).
Miguel OzSoftware EngineerCommented:
I need more specifi information.
Please provide details on how the text file will be filled, For example:
- One line per object.
- The line contains the csv representation of the object public properties.
- Class declaration (DataLibs ) to identify which properties to convert.

Basically you neeed to write two methods:
- In DataLibs class, add a ToCsvString() method that returns the object as csv string. (data1, data2, etc.)
- In your page, add a BuildCsvFile(string filename, List<DataLibs> list) method that saves the list to a text file. Interanlly it loops the list and call ToCsvString()  for every object and save it to the file.

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now