I've tried it from 0 though for testing purposes, again couldn't set
the text for that textbox but could for all the ones from 2 onwards.
On 1 May, 09:19, "David" <david.colliver.N...@revilloc.REMOVETHIS.com>
wrote:
> cntCount will never be 0 as you start it from 1.
>
> --
> Best regards,
> Dave Colliver.http://www.AshfieldFOCUS.com
> ~~http://www.FOCUSPortals.com- Local franchises available
>
> <mj.redfox...@gmail.com> wrote in message
>
> news: oups.com...
>
>
>
> > QUICK ADD: For some reason, in the above I've accidentally deleted the
> > line where if 'Computer' is selected in the drop-down list, then
> > strTemplate is set to "Computer". Sorry about that, the important
> > point in the above is that the line that adds the text to textbox
> > txtLeft2 works fine, so I just need to figure out what is so 'special'
> > about textboxes 1 and 2...
>
> > On 1 May, 08:31, mj.redfox...@gmail.com wrote:
> >> OK, here's the code behind page in full. I didn't post this originally
> >> as it's in a very 'quick and dirty' state at the moment, and needs
> >> tidied, commented and the variables renamed...but this is what I've
> >> been working with It basically adds a variable number of table cells
> >> and textboxes within them, based on the value of 'intAttributes'.
> >> Using this, for some reason I can only set properties of textboxes
> >> txtLeft2 - txtLeft8 (or whatever the upper limit is) - any attempt to
> >> programmatically change the initial text in textboxes txtTest0 or
> >> txtTest1 has no effect. Very, very strange.
>
> >> Partial Class _ShowData
> >> Inherits System.Web.UI.Page
>
> >> Sub Page_Load(ByVal Sender As System.Object, ByVal e As
> >> System.EventArgs) Handles MyBase.Load
>
> >> Dim strTemplate As String
> >> Dim intAttributes As Integer
> >> Dim txtTest As TextBox
> >> Dim trTest As TableRow
> >> Dim tdTest As TableCell
> >> Dim cntCount As Integer
>
> >> strTemplate = ""
> >> intAttributes = 1
>
> >> If Page.IsPostBack Then
> >> If Page.Request.Params.Get("__EVENTTARGET") =
> >> "DropDownList1" Then
> >> strTemplate = DropDownList1.Text
> >> Select Case DropDownList1.Text
> >> Case "Computer"
> >> intAttributes = 8
> >> Case "Generic"
> >> intAttributes = 6
> >> End Select
> >> End If
> >> End If
>
> >> For cntCount = 1 To intAttributes
>
> >> trTest = New TableRow
> >> trTest.ID = "trSpecification" + cntCount.ToString
> >> Page.FindControl("tblSpecification").Controls.Add( trTest)
>
> >> tdTest = New TableCell
> >> tdTest.ID = "tdSpecificationLeft" + cntCount.ToString
> >> Page.FindControl("trSpecification" +
> >> cntCount.ToString).Controls.Add(tdTest)
>
> >> tdTest = New TableCell
> >> tdTest.ID = "tdSpecificationRight" + cntCount.ToString
> >> Page.FindControl("trSpecification" +
> >> cntCount.ToString).Controls.Add(tdTest)
>
> >> txtTest = New TextBox
> >> txtTest.ID = "txtLeft" + cntCount.ToString
> >> If strTemplate = "Computer" Then
> >> If cntCount = 0 Then
> >> txtTest.Text = "Test Text 0"
> >> End If
> >> If cntCount = 1 Then
> >> txtTest.Text = "Test Text 1"
> >> End If
> >> If cntCount = 2 Then
> >> txtTest.Text = "Test Text 2"
> >> End If
> >> End If
> >> Page.FindControl("tdSpecificationLeft" +
> >> cntCount.ToString).Controls.Add(txtTest)
>
> >> txtTest = New TextBox
> >> txtTest.ID = "txtRight" + cntCount.ToString
> >> Page.FindControl("tdSpecificationRight" +
> >> cntCount.ToString).Controls.Add(txtTest)
>
> >> Next
>
> >> End Sub
>
> >> On 30 Apr, 16:55, "Ray Costanzo" <my first name at lane 34 dot
>
> >> commercial> wrote:
> >> > It's possible that what you're trying to do can be done with an
> >> > entirely
> >> > different approach. If you want to post snippets of ASPX and .VB that
> >> > would
> >> > be enough for us to duplicate what you're doing, maybe someone could
> >> > offer
> >> > some alternate routes if they'd seem appropriate.
>
> >> > Ray at work
>
> >> > <mj.redfox...@gmail.com> wrote in message
>
> >> >news: oups.com...
>
> >> > > Hmmmm. The textboxes (there are a few of them created by a FOR...NEXT
> >> > > loop) are actually behaving VERY weirdly, using your suggestion I can
> >> > > now assign a text value to all but the first two, even though the
> >> > > loop
> >> > > handles them all identically!!????
>
> >> > > I'll have another look tomorrow and then report back as this may be
> >> > > useful for other people in the future. I wonder if dynamic generated
> >> > > form elements are just unstable in general?- Hide quoted text -
>
> >> > - Show quoted text -- Hide quoted text -
>
> >> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -