愛麗絲的心情

關於部落格
點點滴滴皆是記錄
步步痕跡皆是煩惱
  • 57130

    累積人氣

  • 3

    今日人氣

    0

    訂閱人氣

DataSet+DropdownList+CodeSmith

一直要試出 TextBox的值帶動DropDownList的清單 原本執著於AJAX 經過不少的挫折 轉念用以前的寫法 但在ddlCustContactId.DataSource = dsContact一直出現 System.NullReferenceException 經過谷歌大神的指導(http://topic.csdn.net/t/20050901/15/4244577.html) 原來是忘了他的需要了 這樣花了我2天 希望這次會順利呀 txtCustComId = (TextBox)FormView1.FindControl("dataCustComId"); ddlCustContactId = (DropDownList)FormView1.FindControl("dataCustContactId"); if (txtCustComId.Text != "") { Session["custComName"] = txtCustComId.Text; ERPClass.Services.CustCompanyService comServices = new CustCompanyService(); TList comList = ERPClass.Data.DataRepository.CustCompanyProvider.Find("CustComName='" + Session["custComName"].ToString() + "'"); DataSet dsCom = new DataSet(); dsCom = comList.ToDataSet(false); Int32 comId = Convert.ToInt32(dsCom.Tables[0].Rows[0]["custComId"].ToString()); ERPClass.Services.CustContactService ContactService = new CustContactService(); TList contactList = ERPClass.Data.DataRepository.CustContactProvider.GetByCustComId(comId); DataSet dsContact = new DataSet(); dsContact = contactList.ToDataSet(false); if (dsContact.Tables[0].Rows.Count > 0) { ddlCustContactId.DataSource = dsContact; ddlCustContactId.DataTextField = "custContactName"; ddlCustContactId.DataValueField = "custContactId"; ddlCustContactId.DataBind(); } }
相簿設定
標籤設定
相簿狀態