TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mahmud Choudhury
NA
4
988
Read and Display CSV data
Jan 12 2015 7:27 AM
Hiya;
I need to read and display data from a csv file in a table format. I then will need to use these data to calculate different values. This is how the CSV file looks:
<table>
<tr>
<td>9 carat gold</td><td>11.87</td>
</tr><tr>
<td>18 carat gold</td><td>23.73</td>
</tr><tr>
<td>Silver</td><td>0.49</td>
</tr><tr>
<td>Platinum</td><td>27.52</td>
</tr>
</table>
I need to display these on a table format on the webpage (able to do that as gridview) then use individual values from the table to work out calculation i.e 10 grams of silver should be worked out by multiplying 0.49 (retrieved from the table) by 10.
That's the code I have so far for GridView:
If File.Exists("metals.csv") Then
Dim data As String() = File.ReadAllLines("metals.csv")
Dim dt As New DataTable()
Dim col As String() = data(0).Split(",")
For Each s As String In col
dt.Columns.Add(s, GetType(String))
Next
For i As Integer = 0 To data.Length - 1
Dim row As String() = data(i).Split(",")
dt.Rows.Add(row)
Next
GridView1.DataSource = dt
GridView1.DataBind()
End If
Is there another way of doing this say by using arrays to assign variables for each metal. I need to make sure they are displayed in a table format.
Thank you
Reply
Answers (
1
)
images slider in gridview asp.net?
Get Users from Domain and Active Directory -PLEASE HELP