看板 Visual_Basic 關於我們 聯絡資訊
各位大大好~我又來問問題了 冏~~z 先說我想做些什麼好了 就如上篇所問的 我把我webform中的東西 全部用一個object陣列包起來 想要傳到user control去做一些處理 感謝大大的回答 我可以順利的找出陣列中原本的東西 但現在又面臨到一個問題 要怎麼把原本在webform中的陣列傳到user control中 以我的理解好像是可以用session或是property來做 我選擇了用property來實作 以下是我在user control中寫的 ===================================================== Property sendComponents() As Object() Get Return Me.ViewState("sendComponents") End Get Set(ByVal Value As Object()) Me.ViewState("sendComponents") = Value Me.rcvComponents = sendComponents End Set End Property ===================================================== 我在webform中寫了以下幾行程式想要傳遞陣列過去 ===================================================== Dim Mycontrol As WebUserControl11 Mycontrol = Me.FindControl("WebUserControl1") Mycontrol.sendComponents = allComponent ===================================================== 可是卻會發生"並未將物件參考設定為物件的執行個體"的錯誤 以在下的理解是 Dim allComponent() As Object = {Me.TextBox1, Me.TextBox2, Me.CheckBox1, Me.CheckBox2, Me.DropDownList1, Me.TextBox3} 這個部份的allComponent是一個物件參考變數 分別指向textbox1,textbox2等等~ 但是並沒有真的的生出實體來 可是我就卡在這個地方不知道該怎麼做才好 又要麻煩大大們囉 文章有些長 先感謝大家耐心的看完~~ 拜託各位囉~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.132.182.104
fumizuki:FindControl() 有找到物件嗎 10/15 10:36
diskk:Property有用Public或Protected宣告嗎 10/15 11:09
danceric:要怎麼確定是否有找到物件? 剛剛試了一下似乎是沒有= = 10/15 14:22
danceric:property沒有宣告public之類的 我現在加上去了@@~~ 10/15 14:22
danceric:所以我的理解好像是錯的=.= 應該是findcontrol那邊的問題 10/15 14:25
danceric:可以了~~感謝大大們~~:D 10/15 14:44