radgrid头作为来自数据库的动态数据我该如何声明呢? [英] radgrid header as a dynamic data from the database how can i declare it ?
本文介绍了radgrid头作为来自数据库的动态数据我该如何声明呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将radgrid标头设置为数据库表中的动态数据,我该如何给它?
i want to set radgrid header as a dynamic data from the database table how can i give it ?
推荐答案
假设table1具有值为AB C的colmn_name。
表2中的ABC列有一些值。
第一次查询table1以获取变量列。
使用逗号分隔登录。
Suppose table1 is having colmn_name with value A B C.
Table 2 is having column A B C with some values.
First fire query on table1 to get columns in variabl.
Use comma separated login for that.
Declare @SelectColum varchar(max)
SELECT @SelectColum = SUBSTRING(
(SELECT ',' + s.colmn_name
FROM table1 s
ORDER BY s.colmn_name
FOR XML PATH('')),2,200000) AS CSV
-- @SelectColum variable having your required column
Select @SelectColum from table2
您不需要在C#中进行任何编码。只需在sql中使用上面的逻辑来获取数据。
如果仍然有疑问,那么探索你的数据库设计。 (表中的关系是什么?
列名?你想要什么输出?
You dont need to do any coding in C#. Just use above logic in sql to get data.
If still having doubt then explore your database design. (What is relation in table?
column name? What output you want?
这篇关于radgrid头作为来自数据库的动态数据我该如何声明呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文