UserControl中的数据表 [英] Datatable in UserControl
本文介绍了UserControl中的数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的用户控件中有一个数据表,gridview在aspx页面中,我想将数据表中的详细信息绑定到gridview.
I have a datatable in my user control, gridview is in aspx page i want to bind the details in datatable to gridview.
推荐答案
在您的usercontrol中,您可以通过使用FindControl方法引用页面中的gridview,之后它是标准数据绑定:
In your usercontrol you can reference the gridview in the page by using the FindControl method, after that it''s standard databinding:
var gridView = this.Page.FindControl("ID OF GRIDVIEW HERE") as GridView;
gridView.DataSource = myDataTable;
gridView.DataBind();
在您的webusercontrol中将数据表设置为公共.
set the datatable as public in your webusercontrol.
//web user control
public static DataTable dt()
{
//your code.
}
//aspx page.
GridView1.DataSource =WebUserControl.dt();
GridView1.DataBind();
这篇关于UserControl中的数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文