even if I don´t have a complete solution for you I want to suggest something. In my opinion the problem of binding a textfile to a datagrid or a datalist is that you can´t use the textfile as a datasource directly. In my opinion the best way is that you first read the textfile into a datatable which you can bind easily to the datalist. For example I can imagine the following code part:
Private Sub BindFileToList()Of course I know that this isn´t the whole solution cause you have to combine the 'fromdatabase' value within the databinding routine but maybe I can show you a way to integrate the textfile into the datalist.
Dim strFilePath As String = "C:\anytextfile"
Dim fs as new FileStream(Server.MapPath (strFilePath), FileMode.Open, FileAccess.Read)
Dim objReader as new StreamReader(fs)
Dim aTable as New DataTable("Table1")While objReader.Peek<>-1
txtString=objReader.ReadLine
aTable.Rows.Add(txtString)
End WhileDataList1.DataSource = aTable
DataList1.DataBind()
End Sub
Regards,
No comments:
Post a Comment