aquafin
August 28th, 2005, 10:31 PM
I am dynamically creating a text box and adding it to the DataList
But it gives me an error at line : 7 ,Specified cast is not valid.
How do i add the text box control to the data list.
1: TextBox1 = New TextBox
2: TextBox1.ID = "tb" & i
3: TextBox1.Style("Position") = "Absolute"
4: TextBox1.Style("Top") = "25px"
5: TextBox1.Style("Left") = "100px"
6: TextBox1.Text = StrQuestion.Substring(0, 1)
7: DG1.Controls.Add(CType(TextBox1, System.Web.UI.Control))
But it gives me an error at line : 7 ,Specified cast is not valid.
How do i add the text box control to the data list.
1: TextBox1 = New TextBox
2: TextBox1.ID = "tb" & i
3: TextBox1.Style("Position") = "Absolute"
4: TextBox1.Style("Top") = "25px"
5: TextBox1.Style("Left") = "100px"
6: TextBox1.Text = StrQuestion.Substring(0, 1)
7: DG1.Controls.Add(CType(TextBox1, System.Web.UI.Control))