导出记事本数据到gridview [英] to export notepad data to gridview

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

问题描述

我想用C#编写示例代码.我想将数据从记事本导出到网格视图...我想要该概念的示例代码...

i want a sample coding in C#..I want to export a data from notepad to grid view...i want a sample coding for that concept...

推荐答案

 foreach (string line1 in File.ReadAllLines(FullFileName))
                    { 
                        string[] parts = line1.Split('','');

                        aRow = tbl.NewRow();
                        aRow["Name"] = parts[0];
                        aRow["Sal"] = parts[1];
                        tbl.Rows.Add(aRow);

                    }
GVContent.DataSource = tbl;
GVContent.DataBind();



希望这对您有所帮助.



Hope this can help you.


记事本是一个文本编辑器,因此您将需要整体或逐行读取文本文件,并确定字段分隔符和位置.

您将需要使用System.IO命名空间,该命名空间包含读写文本文件和流中的类和方法.

Internet上有许多阅读文本文件的代码示例.只是谷歌为他们
Notepad is a text editor, therefore you will need to read the text file as a whole or line-by-line and determine what and where field delimiters are.

You will need to use the System.IO namespace which contains classes and methods from reading and writing text files and streams.

There are plenty of code examples for reading text files, on the internet. Just Google for them


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

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