如何从不同的表加载gridview的单个行的数据 [英] how to load data for individual row of a gridview from different tables

查看:43
本文介绍了如何从不同的表加载gridview的单个行的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请,有人可以帮助我从多个表中将数据作为Gridview的行(而不是列)加载.通过代码.

谢谢你


致以问候
NanKi

Please,Can anyone help me in loading data as Rows(Not as Columns) of Gridview From Multiple Tables.Through Code.

Thanking You


With Regards
NanKi

推荐答案

1)声明一个数据表
2)获取所需的任何数据
3)在数据表中声明一个数据行
4)根据您的要求在行中排列数据
5)将行插入数据表.
同样,您可以从不同的表开始按行排列数据

6)将所有行添加到数据表后,将此数据表分配为网格视图的数据源


试试吧...


1) declare one data table
2) fetch whatever data you want
3) declare one data row to data table
4) arrange data as per your requirement in row
5) insert row into data table.
likewise this you can arrange data row wise from different tables

6) after adding all rows to data table assign this data table as data source to grid view


try it......


DataTable oDtTemp = new DataTable();
for (int iCol = 0; iCol < dsIncentivePay.Tables[0].Columns.Count; iCol++)
{
        oDtTemp.Columns.Add(dsIncentivePay.Tables[0].Columns[iCol].ColumnName.ToString().Trim());
}

for (int iRwCount = 0; iRwCount < dsIncentivePay.Tables[0].Rows.Count; iRwCount++)
{
     DataRow oDrTemp = oDtTemp.NewRow();
     for (int iCol = 0; iCol < dsIncentivePay.Tables[0].Columns.Count; iCol++)
{
     oDrTemp[dsIncentivePay.Tables[0].Columns[iCol].ColumnName.ToString()] = dsIncentivePay.Tables[0].Rows[iRwCount]    [iCol].ToString();
}

     oDtTemp.Rows.Add(oDrTemp);
}


如果无法进行选择查询,则可以创建数据表并与grid绑定,其他解决方案是通过查询"和创建模板"列选择可能的数据在网格中并添加控件,您可以分配值,并且可以再次更改此值而无需再次创建数据表,以上所有解决方案都是根据情况而定的....
If you can not able to make a possible Select Query, then you can create datatable and bound with grid , other solution is select possible data by Query and Create template column in grid and add controls and you can assign values and you can change this values without making datatable again , all above solution is situational, what do you want ....


您好,

解决方案1:创建存储过程并调用.......

解决方案2:在sql中创建临时表,将其他表中的数据加载到临时表中,然后将数据绑定到Grid View或任何其他数据绑定控件非常容易...
Hi,

Solution 1: Create stored procedure and call.......

Solution 2: create temporary table in sql,load the data from different table into the temporary table, then it is very easy to bind the data to Grid View or any other data bound controls...


这篇关于如何从不同的表加载gridview的单个行的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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