Error
-
Dim id As Integer = Request.QueryString("ui")
Dim cmd2 As String = ("Select Specification from DefineSpecification where CategoryID=" + id.ToString())
Dim rdr2 As IDataReader = db.ExecuteReader(CommandType.Text, cmd2)
Dim conn As New SqlConnection
Dim cmd As New SqlCommand("Select Count(*) from DefineSpecification Where CategoryID=" + id.ToString(), conn)
conn.ConnectionString = ConfigurationManager.ConnectionStrings("See2Buy").ConnectionString
conn.Open()
Dim count As Int32 = Convert.ToInt32(cmd.ExecuteScalar())
While rdr2.Read
Dim lbl = New Label()
lbl.Width = "140"
lbl.Text = rdr2.Item("Specification")
Panel4.Controls.Add(lbl)
For counter2 As Integer = 1 To count
Dim txt = New TextBox()
txt.Width = "140"
txt.ID = "TextBoxID" + counter2.ToString
Panel4.Controls.Add(txt)
Dim txt1 As TextBox = CType(Panel4.FindControl("TextBoxID" + counter2.ToString()), TextBox)
Dim txt2 = CStr(txt1.Text)
Dim cmd3 As String = "Insert into Specification(SpecificationHeading,SpecificationDescription)Values('" + lbl.Text + "','" + txt2 + "')"
Dim dbcmd As DbCommand = db.GetSqlStringCommand(cmd3)
db.ExecuteNonQuery(dbcmd)
Next
End WhileError : Multiple controls with the same ID 'TextBoxID1' were found. FindControl requires that controls have unique IDs.
-
Dim id As Integer = Request.QueryString("ui")
Dim cmd2 As String = ("Select Specification from DefineSpecification where CategoryID=" + id.ToString())
Dim rdr2 As IDataReader = db.ExecuteReader(CommandType.Text, cmd2)
Dim conn As New SqlConnection
Dim cmd As New SqlCommand("Select Count(*) from DefineSpecification Where CategoryID=" + id.ToString(), conn)
conn.ConnectionString = ConfigurationManager.ConnectionStrings("See2Buy").ConnectionString
conn.Open()
Dim count As Int32 = Convert.ToInt32(cmd.ExecuteScalar())
While rdr2.Read
Dim lbl = New Label()
lbl.Width = "140"
lbl.Text = rdr2.Item("Specification")
Panel4.Controls.Add(lbl)
For counter2 As Integer = 1 To count
Dim txt = New TextBox()
txt.Width = "140"
txt.ID = "TextBoxID" + counter2.ToString
Panel4.Controls.Add(txt)
Dim txt1 As TextBox = CType(Panel4.FindControl("TextBoxID" + counter2.ToString()), TextBox)
Dim txt2 = CStr(txt1.Text)
Dim cmd3 As String = "Insert into Specification(SpecificationHeading,SpecificationDescription)Values('" + lbl.Text + "','" + txt2 + "')"
Dim dbcmd As DbCommand = db.GetSqlStringCommand(cmd3)
db.ExecuteNonQuery(dbcmd)
Next
End WhileError : Multiple controls with the same ID 'TextBoxID1' were found. FindControl requires that controls have unique IDs.
KhandelwalA wrote:
Error : Multiple controls with the same ID 'TextBoxID1' were found. FindControl requires that controls have unique IDs.
KhandelwalA wrote:
For counter2 As Integer = 1 To count Dim txt = New TextBox() txt.Width = "140" txt.ID = "TextBoxID" + counter2.ToString Panel4.Controls.Add(txt) Dim txt1 As TextBox = CType(Panel4.FindControl("TextBoxID" + counter2.ToString()), TextBox) Dim txt2 = CStr(txt1.Text) Dim cmd3 As String = "Insert into Specification(SpecificationHeading,SpecificationDescription)Values('" + lbl.Text + "','" + txt2 + "')" Dim dbcmd As DbCommand = db.GetSqlStringCommand(cmd3) db.ExecuteNonQuery(dbcmd) Next
Check your code. You error clearly saying that, The ID which is generated for Texbox is not unique. Means Same Textbox ID generating multiple time.
cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net View My Recent Article
-
Dim id As Integer = Request.QueryString("ui")
Dim cmd2 As String = ("Select Specification from DefineSpecification where CategoryID=" + id.ToString())
Dim rdr2 As IDataReader = db.ExecuteReader(CommandType.Text, cmd2)
Dim conn As New SqlConnection
Dim cmd As New SqlCommand("Select Count(*) from DefineSpecification Where CategoryID=" + id.ToString(), conn)
conn.ConnectionString = ConfigurationManager.ConnectionStrings("See2Buy").ConnectionString
conn.Open()
Dim count As Int32 = Convert.ToInt32(cmd.ExecuteScalar())
While rdr2.Read
Dim lbl = New Label()
lbl.Width = "140"
lbl.Text = rdr2.Item("Specification")
Panel4.Controls.Add(lbl)
For counter2 As Integer = 1 To count
Dim txt = New TextBox()
txt.Width = "140"
txt.ID = "TextBoxID" + counter2.ToString
Panel4.Controls.Add(txt)
Dim txt1 As TextBox = CType(Panel4.FindControl("TextBoxID" + counter2.ToString()), TextBox)
Dim txt2 = CStr(txt1.Text)
Dim cmd3 As String = "Insert into Specification(SpecificationHeading,SpecificationDescription)Values('" + lbl.Text + "','" + txt2 + "')"
Dim dbcmd As DbCommand = db.GetSqlStringCommand(cmd3)
db.ExecuteNonQuery(dbcmd)
Next
End WhileError : Multiple controls with the same ID 'TextBoxID1' were found. FindControl requires that controls have unique IDs.
-
I did that but still getting the same error
-
I did that but still getting the same error
KhandelwalA wrote:
I did that
But in the code you have posted above,i cannot find where you have done that.
himanshu