benjaminplum
New Member
I'm new to Asp.net and site building, but I started with Webmatrix Webpages and I'm actually progressing very much in my website.But I'm now stuck in a piece of razor code. I get the error:Object reference not set to an instance of an object.in line:foreach(Control c1 in Page.Controls)\[code\]@{ var db = Database.Open("DOM Coins"); var codigo_campo_ID_unico=0; var valor_BC=0; if(IsPost){ foreach(Control c1 in Page.Controls){ foreach(Control c in c1.Controls){ if (c.GetType().ToString() == "System.Web.UI.WebControls.TextBox"){ if (c.ID=="BC_8"){ if (c.ID.Substring(0,2)=="BC"){ codigo_campo_ID_unico=int.Parse(c.ID.Substring(3,c.ID.Length-3)); valor_BC=int.Parse(Request[c.ID]); db.Execute("UPDATE Coleccao SET Quantidade_BC=@valor_BC WHERE Id=@codigo_campo_ID_unico"); } } } } } }}\[/code\]Teh reason I want to do this is because I'm creating textboxes dinamically, each one with a different ID, and I want to iterate through all of them and insert the data to the DB.Any help would be apreciated.Thanks in advance,Dinis.