using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Data.SqlClient; namespace sdit ... { /**//// <summary> /// marchant_search_new的摘要说明。 /// </summary> public class marchant_search_new : System.Web.UI.Page ...{ private SqlConnection Sqlconn; private SqlDataAdapter da; protected System.Web.UI.WebControls.DataList dlst; protected System.Web.UI.WebControls.DataList dlstBig; protected System.Web.UI.WebControls.Label lblBigname; protected System.Web.UI.WebControls.TextBox txtBigID1; protected sdit.sjkweb.sqlb Sqlb1 =new sdit.sjkweb.sqlb(); private void Page_Load(object sender, System.EventArgs e) ...{ if(!IsPostBack) ...{ DlstbigBind(); DlstBind(Request["BigType_ID"]); txtBigID1.Text=Request["BigType_ID"]; Sqlb1.BindList1(txtBigID1.Text,Request["SmallType_ID"],Request["bbid"],"",""); } // 在此处放置用户代码以初始化页面 } private void DlstbigBind() ...{ string strqg="Select * from BigType"; this.Sqlconn=new SqlConnection(database.conStr); this.da=new SqlDataAdapter(strqg,this.Sqlconn); DataSet dsqg=new DataSet(); this.da.Fill(dsqg,"temp"); DataTable dtqg=new DataTable(); dtqg=dsqg.Tables[0]; this.dlstBig.DataSource=dtqg; this.dlstBig.DataBind(); DlstBind(dtqg.Rows[0].ItemArray[0].ToString()); this.lblBigname.Text=dtqg.Rows[0].ItemArray[1].ToString(); } private void DlstBind(string bigid) ...{ string strqg="Select SmallType_ID as aa ,SmallType_Name as b from SmallType where BigType_ID='" + bigid + "'"; this.Sqlconn=new SqlConnection(database.conStr); this.da=new SqlDataAdapter(strqg,this.Sqlconn); DataSet dsqg=new DataSet(); this.da.Fill(dsqg,"temp"); DataTable dtqg=new DataTable(); dtqg=dsqg.Tables[0]; this.dlst.DataSource=dtqg; this.dlst.DataBind(); } private void Dlst2Bind(DataList dlst,string strID) ...{ string strqg="Select id as aa ,name as b from bankbrand where smalltype_ID='"+ strID +"'"; this.Sqlconn=new SqlConnection(database.conStr); this.da=new SqlDataAdapter(strqg,this.Sqlconn); DataSet dsqg=new DataSet(); this.da.Fill(dsqg,"temp"); DataTable dtqg=new DataTable(); dtqg=dsqg.Tables[0]; dlst.DataSource=dtqg; dlst.DataBind(); } Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码 override protected void OnInit(EventArgs e) ...{ /**/////程序设计:小鱼儿 //QQ:313116937 // 联系方式:313116937@163.com // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } /**//// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() ...{ this.dlstBig.ItemCommand += new System.Web.UI.WebControls.DataListCommandEventHandler(this.dlstBig_ItemCommand); this.dlstBig.ItemDataBound += new System.Web.UI.WebControls.DataListItemEventHandler(this.dlstBig_ItemDataBound); this.dlst.ItemCreated += new System.Web.UI.WebControls.DataListItemEventHandler(this.dlst_ItemCreated); this.dlst.ItemCommand += new System.Web.UI.WebControls.DataListCommandEventHandler(this.dlst_ItemCommand); this.dlst.ItemDataBound += new System.Web.UI.WebControls.DataListItemEventHandler(this.dlst_ItemDataBound); this.Load += new System.EventHandler(this.Page_Load); } #endregion private void dlst_ItemDataBound(object sender, System.Web.UI.WebControls.DataListItemEventArgs e) ...{ if (e.Item.ItemType==ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem) ...{ DataList dlstChild =(DataList)e.Item.FindControl("dlstChild"); TextBox txtID = (TextBox)e.Item.FindControl("txtID"); Dlst2Bind(dlstChild,txtID.Text ); //LinkButton LinkButton1=(LinkButton)e.Item.FindControl("LinkButton1"); //LinkButton1.Attributes.Add("onclick","window.open('http://www.hao123.com');return false;"); } DataList DataList1 =(DataList)e.Item.FindControl("DataList1"); } private void dlst_ItemCreated(object sender, System.Web.UI.WebControls.DataListItemEventArgs e) ...{ if (e.Item.ItemType==ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem) ...{ DataList dlstChild =(DataList)e.Item.FindControl("dlstChild"); dlstChild.ItemDataBound += new System.Web.UI.WebControls.DataListItemEventHandler(this.dlstChild_ItemDataBound); dlstChild.ItemCommand += new System.Web.UI.WebControls.DataListCommandEventHandler(this.dlstChild_ItemCommand); } } private void dlstChild_ItemDataBound(object sender, System.Web.UI.WebControls.DataListItemEventArgs e) ...{ if (e.Item.ItemType==ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem) ...{ //LinkButton LinkButton1=(LinkButton)e.Item.FindControl("LinkButton2"); //LinkButton1.Attributes.Add("onclick","window.open('http://www.sina.com')"); } } private void dlst_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e) ...{ if(e.CommandName=="imagebutton1") ...{ DataList dlstChild =(DataList)e.Item.FindControl("dlstChild"); dlstChild.Visible=!dlstChild.Visible; ImageButton img1 =(ImageButton)e.Item.FindControl("img1"); if(dlstChild.Visible) ...{ img1.ImageUrl="images/m_list_oo.gif"; } else ...{ img1.ImageUrl="images/m_list_pp.jpg"; } } if(e.CommandName=="lbt1") ...{ DataList dlstChild=(DataList)e.Item.FindControl("dlstChild"); LinkButton lbt1=(LinkButton)e.Item.FindControl("lbt1"); TextBox txtID =(TextBox) e.Item.FindControl("txtID"); Sqlb1.BindList1(txtBigID1.Text,txtID.Text,"","",""); } } private void dlstChild_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e) ...{// if(e.CommandName=="LinkButton2")// { // LinkButton LinkButton2=(LinkButton)e.Item.FindControl("LinkButton2");// TextBox txtchid=(TextBox)e.Item.FindControl("txtchid");// Sqlb1.BindList1("","",txtchid.Text,"","");// LinkButton LinkButton2=(LinkButton)LinkButton2.Parent.Parent.FindControl("LinkButton2");// string sdf1="marchant_search_new.aspx?pid=txtchid.Text"; // } } private void dlstBig_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e) ...{ if(e.CommandName=="lkbBIGName") ...{ TextBox txtbigid=(TextBox)e.Item.FindControl("txtbigid"); LinkButton lkbBIGName = (LinkButton) e.Item.FindControl("lkbBIGName"); DlstBind(txtbigid.Text); this.lblBigname.Text=lkbBIGName.Text; txtBigID1.Text=txtbigid.Text; } } private void dlstBig_ItemDataBound(object sender, System.Web.UI.WebControls.DataListItemEventArgs e) ...{ if (e.Item.ItemType==ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem) ...{ LinkButton lkbBIGName =(LinkButton)e.Item.FindControl("lkbBIGName"); lkbBIGName.Attributes.Add("onclick","chgCol('"+lkbBIGName.ClientID + "');"); } } }}