I have this code:
[code]

Protected Sub Komponenter1_ClickUserControl(ByVal sender As Object, ByVal e As System.EventArgs) Handles Komponenter1.ClickUserControl
Dim userC As UserControl = CType(sender, UserControl)
If Not userC Is Nothing Then
Dim userC2 As UserControl = CType(sender, UserControl)
Dim txt1 As String
Dim i As Integer

txt1 = userC.ID

If txt1.Length = 12 Then
i = 1
Else
i = 2
End If

txt1 = CInt(txt1.Substring(11, i))

userC2.ID = "Komponenter" + CStr(txt1)
userC2.Visible = True
end sub
[code]
which works fine. But if I change the code in the two last line to
Code:
userC2.ID = "Komponenter" + CStr(txt1+1)
userC2.Visible = True
then I receive an error:
Code:
Multiple controls with the same ID 'Komponenter2' were found. FindControl requires that controls have unique IDs. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: Multiple controls with the same ID 'Komponenter2' were found. FindControl requires that controls have unique IDs.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 

[HttpException (0x80004005): Multiple controls with the same ID 'Komponenter2' were found. FindControl requires that controls have unique IDs.]
   System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls) +134
   System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls) +203
   System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +164
   System.Web.UI.Control.FindControl(String id) +9
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +74
   System.Web.UI.Page.ProcessRequestMain() +1277

 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
Why can't I do that?

The code that I write is needed for an app with a lot of order lines where the next order line becomes visible if the current order line is clicked.