如何取出Panel中的控件
单按钮后动态加载了一个GridView到panel
需要在次按下按钮后向GridView中在添加一条记录
取不出Panel空件中GridView
一:
foreach (System.Web.UI.Control control in PanelGv.Controls)
{
if (control.GetType().Name == "GridView ")
{
GridView gv = (GridView)control;
return gv;
}
二:
GridView gv = (GridView)this.FindControl( "aa ")
这两种办法都取不到
求办法
------解决方案--------------------DataTable ds = new DataTable();
ds.Columns.Add( "id ", typeof(string));
ds.Rows.Add( "aaaaaaaaaa ");
GridView dv = (GridView)Panel1.FindControl( "GridView1 ");
dv.DataSource = ds;
dv.DataBind();
测试过了