将数组绑定到数据网格 [英] Bind array to data grid

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

问题描述

在我的项目中,我有一个二维数组

昏暗的arrValues(1到12、1到3)

其中column1用于存储月份名称,例如jan,feb,... dec

第2列用于收费金额(数字)

第3列表示收到的金额(数字)

现在我想将此数据复制到数据网格中.
你能给我确切的代码怎么做吗?
thnks.

in my project i have a 2d array

Dim arrValues(1 To 12, 1 To 3)

where column1 is for storing month name e.g jan, feb ,... dec

column2 is for amountcharged (number)

column3 is for amountreceived (number)

now i want to copy this data into data grid.
can u manage to give me exact code how to do it?
thnks.

推荐答案



我不确定这是否是您所需要的.
您可以保存阵列详细信息,并将数据网格来源到阵列.
您可以使用DataBind功能根据您在Datagrid中的要求修改列的表示形式.

请让我知道是否需要更详细的信息;
Hi

I am not sure if this is what you require.
You can save your array details and source your datagrid to the array.
You can modify presentation of columns according to your requirement in Datagrid using DataBind feature.

Please let me know if you need in more detail;


是的,我需要将数组绑定到数据网格,但是我不知道该怎么做.我没有获取代码来执行此操作.
Yes i require binding of array to data grid but i dont know how to do it. m not getting code to do this.


您可以只填充名为array1的数组/数据列表.

将您的网格视图ID视为gridID1,为此使用PFB代码:
为确保您没有填充空数组,
you can just populate your array/datalist named array1.

considering your grid view id as gridID1, PFB code for this:
To make sure you are not populating an empty array,
if(array1.Count > 0)
{
    gridID1.DataSource = array1;
    gridID1.DataBind();
}


这是C#语言,我不确定VB语法,但这并不难.


This is in C#, I am not sure of VB syntax, but it shd not be very difficult.


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

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