Panel
-
Hiiiii......i m adding n number of text boxes dynamically in a panel. but when i m going to save those values. it gives me error. My code and error is :
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 = 0 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 is: Multiple controls with the same ID 'TextBoxID0' were found. FindControl requires that controls have unique IDs. pleas guide me
-
Hiiiii......i m adding n number of text boxes dynamically in a panel. but when i m going to save those values. it gives me error. My code and error is :
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 = 0 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 is: Multiple controls with the same ID 'TextBoxID0' were found. FindControl requires that controls have unique IDs. pleas guide me
in which line are you getting this error....
Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]
-
in which line are you getting this error....
Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]
in this line Dim txt1 As TextBox = CType(Panel4.FindControl("TextBoxID" + counter2.ToString()), TextBox)
-
Hiiiii......i m adding n number of text boxes dynamically in a panel. but when i m going to save those values. it gives me error. My code and error is :
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 = 0 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 is: Multiple controls with the same ID 'TextBoxID0' were found. FindControl requires that controls have unique IDs. pleas guide me
hi this error is quite obvious because when datareader read second row from database counter2 in your for loop will again have same value. So, declare one counter before while loop and increament that counter in for loop.this will solve your problem
himanshu
-
hi this error is quite obvious because when datareader read second row from database counter2 in your for loop will again have same value. So, declare one counter before while loop and increament that counter in for loop.this will solve your problem
himanshu
thanks bro :)
-
hi this error is quite obvious because when datareader read second row from database counter2 in your for loop will again have same value. So, declare one counter before while loop and increament that counter in for loop.this will solve your problem
himanshu
hiiiii........as u told me to add counter before while...i added and incremented in for loop.........bt still the same error...can u tell me where to use that specifically in that counter