Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Error

Error

Scheduled Pinned Locked Moved ASP.NET
databasedesignhelp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KhandelwalA
    wrote on last edited by
    #1

    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 While

    Error : Multiple controls with the same ID 'TextBoxID1' were found. FindControl requires that controls have unique IDs.

    A H 2 Replies Last reply
    0
    • K KhandelwalA

      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 While

      Error : Multiple controls with the same ID 'TextBoxID1' were found. FindControl requires that controls have unique IDs.

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • K KhandelwalA

        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 While

        Error : Multiple controls with the same ID 'TextBoxID1' were found. FindControl requires that controls have unique IDs.

        H Offline
        H Offline
        himanshu2561
        wrote on last edited by
        #3

        KhandelwalA wrote:

        txt.ID = "TextBoxID" + counter2.ToString

        As i told you in previous post dont use counter2. Instead create a new counter(c1) and increament it in your for loop. txt.ID = "TextBoxID" + c1.ToString

        himanshu

        K 1 Reply Last reply
        0
        • H himanshu2561

          KhandelwalA wrote:

          txt.ID = "TextBoxID" + counter2.ToString

          As i told you in previous post dont use counter2. Instead create a new counter(c1) and increament it in your for loop. txt.ID = "TextBoxID" + c1.ToString

          himanshu

          K Offline
          K Offline
          KhandelwalA
          wrote on last edited by
          #4

          I did that but still getting the same error

          H 1 Reply Last reply
          0
          • K KhandelwalA

            I did that but still getting the same error

            H Offline
            H Offline
            himanshu2561
            wrote on last edited by
            #5

            KhandelwalA wrote:

            I did that

            But in the code you have posted above,i cannot find where you have done that.

            himanshu

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups