在GridView中将数据表绑定到Gridview [Template Field] [英] Bind datatable to Gridview with in GridView[Template Field]
本文介绍了在GridView中将数据表绑定到Gridview [Template Field]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的Web应用程序中,我添加了一个gridview GridView1并添加了另一个gridview GridView2,并在GridView1s模板字段中添加了标签.我可以使用代码Eval("Name")将数据表中的数据绑定到标签.然后,我想绑定另一个数据表到GridView2.通过使用Sql数据源控件,我可以将数据绑定到datagrid视图,但是我想使用c#.net代码将数据绑定到
In my web application me add a gridview GridView1 and add another gridview GridView2,and label to GridView1s template field .i can bind data in datatable to label using the code Eval("Name").Then i want to bind another datatable to GridView2.By using Sql data source control i can bind the data to datagrid view but i want to bind data using c#.net code
推荐答案
GridView2是模板字段在Gridview1内部.因此我无法使用代码绑定数据
GridView2 is a template field inside the Gridview1.So i cant bind data using the code
gridView2.DataSource = dataTable;
gridView2.DataBind();
我假设您现在拥有DataTable
.
I assume you have theDataTable
now.
gridView2.DataSource = dataTable;
gridView2.DataBind();
上面的代码将神奇.
The above code will do the magic.
这篇关于在GridView中将数据表绑定到Gridview [Template Field]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文