Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

CreateChildControls problem

[es] :: .NET :: CreateChildControls problem

[ Pregleda: 2410 | Odgovora: 0 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

||NeX||
Nedim Šabić
Vlasnik SEO.ba
BiH

Član broj: 1430
Poruke: 1733
*.as53.tr.bih.net.ba.



+4 Profil

icon CreateChildControls problem26.12.2002. u 00:59 - pre 236 meseci
U CreateChildControls pokusavam da dodam jedan kontrol stranici.
Isprva sve fercera i ja mogu stranicu reloadovati par puta ili se na nju vratiti (znaci ProcessPostBack event works fine) medjutim nakon sto promijenim vrijednost DropDownList koja je dio child control stabla te stranice dobijem sljedeci error:

Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Specified cast is not valid.

Source Error:

Line 114: ctrlBlah.ID = "ctrlBlahContainer"
Line 115: Controls.Remove(ctrlBlah);
Line 116: Controls.Add(ctrlBlah);
Line 117: }
Line 118:

Ovo je stack trace:

[InvalidCastException: Specified cast is not valid.]
System.Web.UI.StateBag.LoadViewState(Object state) +26
System.Web.UI.Control.LoadViewState(Object savedState) +31
System.Web.UI.WebControls.WebControl.LoadViewState(Object savedState) +36
System.Web.UI.WebControls.Label.LoadViewState(Object savedState) +14
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +125
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +311
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +311
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +311
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +311
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +311
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +311
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +311
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +311
System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +311
System.Web.UI.Control.AddedControl(Control control, Int32 index) +291
System.Web.UI.ControlCollection.Add(Control child) +153
ImeMojeKlase.CreateChildControls() in fullname of my file:116
System.Web.UI.Control.EnsureChildControls() +100
System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +22
System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +316
System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +316
System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +316
System.Web.UI.Control.FindControl(String id) +9
System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +201
System.Web.UI.Page.ProcessRequestMain() +872


ViewState koristi ID da bi assign state kontroli. Dakle ID mora biti jedinstven kako ne bi pokusao da da state nekoj kontroli ciji to state nije. To mi se isprva cinilo kao uzrok ove greske. Medjutim najgore je sto ponasanje uopste nije predvidljivo tj. desice se samo kada promijenim value DropDownList (ciji elementi nisu controls! dakle nemaju ID-a) i to ne odma , vec mozda tek nakon par reload-ova. Svaka kontrola na toj stranici ima jedinstven ID, ali... dzabe
 
Odgovor na temu

[es] :: .NET :: CreateChildControls problem

[ Pregleda: 2410 | Odgovora: 0 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.