• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 408
  • 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);
            Test.DataBind();
        }
x.txt
0
solution1368
Asked:
solution1368
  • 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?)
0
 
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).
0
 
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

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