how to display dynamically created controls data in c#
-
Hi All, Iam creating a table dynamically with this structure Rno Name Address 1 xyz TextBox1 2 yzx TextBox2 3 aaa TextBox3 Now the user enters data into text boxs.I want to get those data.How can i do this.Iam creating textbox id's dynamically.This is my code for (int i = 0; i < 10; i++) { string boxName = "monthData" + (i).ToString(); TextBox tb = form1.FindControl(boxName) as TextBox; string txt = tb.Text.ToString(); Response.Write(txt.ToString()); } Iam accessing id's of text box's but there is an error "Object reference not set to an instance of the object" in string txt = tb.Text.ToString(). Please help me on this.
i want to join this group
-
Hi All, Iam creating a table dynamically with this structure Rno Name Address 1 xyz TextBox1 2 yzx TextBox2 3 aaa TextBox3 Now the user enters data into text boxs.I want to get those data.How can i do this.Iam creating textbox id's dynamically.This is my code for (int i = 0; i < 10; i++) { string boxName = "monthData" + (i).ToString(); TextBox tb = form1.FindControl(boxName) as TextBox; string txt = tb.Text.ToString(); Response.Write(txt.ToString()); } Iam accessing id's of text box's but there is an error "Object reference not set to an instance of the object" in string txt = tb.Text.ToString(). Please help me on this.
i want to join this group
Maybe because you're starting iteration with i=0? Start with 1.
Visit my blog at http://dotnetforeveryone.blogspot.com