Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 20th, 2004, 12:19 PM
Authorized User
 
Join Date: Feb 2004
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default Referencing a Item in a Repeater

Hi. Does anyone know the VB snytax for referencing a control created by a Data Repeater?

I have been looking into the Repeater.Items collection without success. I have been successful in returning the index value for submit buttons through the ItemIndex prpoert, which would be the first start of building a variable to reference a textbox in the same row of the Repeater.

Any pointers would be very helpful.

Dave
 
Old February 20th, 2004, 12:58 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Repeater.Items(IndexValue).Controls(IndexValue)

or

Repeater.Items(IndexValue).FindControl(ControlID)
 
Old February 20th, 2004, 01:24 PM
Authorized User
 
Join Date: Feb 2004
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, Brian.

I used the first example: Repeater.Items(0).Controls(3) with a Response.Write() & received the follwing: System.Web.UI.WebControls.TextBox

I was unable to return that textbox's text value by adding '.Text' to the end of the statement. Any ideas how I can access the vaule that the textbox actually contains?

Also, I tried the second example: Repeater.Items(0).FindControl(tbxEntityName) but received the error that tbxEntityName was not declared. 'tbxEntityName' is the name of the textbox in the Repeater. What should 'ControlID' refer to?

Dave
 
Old February 20th, 2004, 01:29 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Repeater.Items(0).FindControl("tbxEntityName")

Use quotes around the tbxEntityName

 
Old February 20th, 2004, 02:38 PM
Authorized User
 
Join Date: Feb 2004
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

stu -

That method works as well.

I used this to get to the value:

objNameTextBox = objRepeater.Items(0).FindControl("tbxEntityName")
objUpParameter2.Value = objNameTextBox.Text

Thanks!

Dave
 
Old February 20th, 2004, 03:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Try:

CType(Repeater.Items(0).Controls(3), TextBox).Text

You have to convert it to a textbox to access the text property. By default, The control object doesn't have a text property.

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
Referencing another field and more scandalous Access VBA 1 January 30th, 2007 09:28 AM
referencing an object in an edit item template dan195 ASP.NET 1.0 and 1.1 Basics 3 September 25th, 2006 07:15 AM
repeater control only shows last Item info trancehead ASP.NET 2.0 Basics 0 July 3rd, 2006 09:06 AM
Want Combo Box first item if only 1 item markw707 Access 3 June 9th, 2004 04:03 PM
Find Out First Item of each item Group Jane SQL Language 1 November 22nd, 2003 12:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.