将文本数据导入到gridview [英] Import text data into gridview

查看:91
本文介绍了将文本数据导入到gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的文本文件中有逗号分隔的数据(例如)

约翰,
纽约,
32323332,
男性,
maira,
卡拉奇,
34343344,



像这样的plz告诉我如何将这些数据导入asp.net的gridview.
;)

I have data in text file with comma separated (e.g.)

john,
new york,
32323332,
male,
maira,
karac
34343344,
female


Like this plz tell me how should I import this data into gridview of asp.net.
;)

推荐答案

OleDbConnection允许您连接到文本文件.检查出来.
OleDbConnection allows you to connect to the text files. Check that out.


正如另一响应者所说,使用OleDbConnection连接到文本文件.
或者,您可以简单地阅读文本文件.使用System.IO命名空间和File类来完成此操作.
如果您不知道如何阅读文件,可以在Google上搜索如何阅读文本文件"(如果您考虑我的建议,请购买一本书).
将数据读入DataTable.
GridView 绑定到DataTable
As the other responder said use OleDbConnection to connect to the text files.
Or you may simply read the text file. Use System.IO namespace and File Class to accomplish this.
You may search Google for "how to read text file", if you don''t know how to read files (if you consider my suggestion, buy a book).
Read the data into DataTable.
Bind the GridView to the DataTable


这篇关于将文本数据导入到gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆