如何从gridview中检索数据并以字符串形式存储 [英] How to retrive data from gridview and store in string

查看:56
本文介绍了如何从gridview中检索数据并以字符串形式存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi

i使用



hi
i have use

using Spire.Pdf;
using Spire.Pdf.Grid;
using Spire.Pdf.Graphics;
using Spire.Pdf.HtmlConverter;





现在我想要反向网格视图数据



now i want retrive grid-view data in

PdfTextWidget textWidget = new PdfTextWidget(griddata, font, brush);




我上面使用的代码griddata中的
,我必须在那里用来从gridview中检索所有数据吗?



我尝试过:



string [] str = new string [gridtable.Rows。计数];

for(int i = 0; i< gridtable.Rows.Count; i ++)

{



str [i] = gridtable.Rows [i] .Cells [0] .Value.ToString();



}

PdfTextWidget textWidget = new PdfTextWidget(str.ToString(),font,brush);



in above code griddata i had use , what i have to use there for retrive all data from gridview?

What I have tried:

string[] str = new string[gridtable.Rows.Count];
for (int i = 0; i < gridtable.Rows.Count; i++)
{

str[i] = gridtable.Rows[i].Cells[0].Value.ToString();

}
PdfTextWidget textWidget = new PdfTextWidget(str.ToString(), font, brush);

推荐答案

通过此代码,您将只获得数据网格的第一列。

by this code you will only get the first column of data grid.
string[] str = new string[gridtable.Rows.Count];
 for (int i = 0; i < gridtable.Rows.Count; i++)
 {

 str[i] = gridtable.Rows[i].Cells[0].Value.ToString();

 }
 PdfTextWidget textWidget = new PdfTextWidget(str.ToString(), font, brush); 







将数据网格数据存储在需要存储在多维字符串数组中的字符串中。

使用下面的代码从datagrid获取所有数据。






to store datagrid data in string you need to store in multidimensional string array.
use below code to fetch all data from datagrid.

string[,] str = new string[gridtable.Rows.Count,gridtable.Columns.Count];

for (int i = 0;i< gridtable.Rows.Count; i++)
 {
	for(int j=0;j<gridtable.Rows.Count; j++)
	{
 		str[i,j] = gridtable.Rows[i].Cells[j].Value.ToString();
	}	
 }





我没有使用'PdfTextWidget'但是我用了'iTextsharp'DLL来创建PDF。

您可以使用上述相同的循环序列将数据从多维字符串数组写入PDF。



I haven't used 'PdfTextWidget' but ive used 'iTextsharp' DLL's to create PDF.
You can use the above same looping sequence to write data to PDF from multidimensional string array.


这篇关于如何从gridview中检索数据并以字符串形式存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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