Resolving a controls name in the asp.net Repeater control

How not to access an asp.net Repeater control's data 

 

It would appear that between some .net updates Microsoft likes to change how Asp.net names controls.

>
For i As Integer = 0 To ilsn - 1       
 Dim controlname As String = "repGrid:_ctl" & i + 1 & ":txtOrder"
 Dim controlnameVal As Int32 = Request(controlname)
 StoreVal( ControlNameVal)
Next

This approach is safer

>
For Each di In repGrid.Items       
 Dim controlnameVal As Int32 = ConvertToINT( di.FindControl("txtOrder"))
 StoreVal( ControlNameVal)
Next

 

When your using an asp.net Repeater control you need to call find control on the given row in order for it to properly resolve the name.

Also of interest is this little nugget found on The Scripts forum:

.net Changing $ to _ ?

http://www.thescripts.com/forum/thread703070.html

ms went down a rat hole with names and ids. they started with ":" as

separator, but found this was illegal in an id or name, so replaced it

"$". then they realized "$" was illegal in an id when they wanted xhtml

compliance, so they changed it to "_" in an id.

Comments [0]
All comments require the approval of the site owner before being displayed.
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, super, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview