·简单问题,为什么获取不到控件实例?
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Repeater0 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Repeater1.DataSource = pageDs();
Repeater1.DataBind();
//------(为什么找不到DropDownList1这个控件?)
DropDownList DDl = (DropDownList)Repeater1.FindControl( "DropDownList1 ");
string n = DDl.DataValueField.ToString();
//------
}
protected PagedDataSource pageDs()
{
string constr = ConfigurationManager.ConnectionStrings[ "NorthwindConnectionString "].ConnectionString;
SqlConnection sqlCon = new SqlConnection(constr);
DataSet Ds = new DataSet();
SqlDataAdapter sqlDa1 = new SqlDataAdapter( "select * from Orders ", sqlCon);
sqlDa1.Fill(Ds, "01 ");
SqlDataAdapter sqlDa2 = new SqlDataAdapter( "select * from [Order Details] ", sqlCon);
sqlDa2.Fill(Ds, "02 ");
Ds.Relations.Add( "All ", Ds.Tables[ "01 "].Columns[ "OrderID "], Ds.Tables[ "02 "].Columns[ "OrderID "]);
PagedDataSource pageDs = new PagedDataSource();
pageDs.DataSource = Ds.Tables[ "01 "].DefaultView;
pageDs.AllowPaging = true;
pageDs.PageSize = 16;
pageDs.CurrentPageIndex = Convert.ToInt32(Request.QueryString[ "page "]);
return pageDs;
}
protected void &