Mondeo Posted April 17, 2007 Posted April 17, 2007 I have several literal controls on my page, Literal1, Literal2, Literal3 etc I have a function which takes an index Private Sub UpdateLiteral(byval index as int16) ... End Sub In that sub I want to update the corresponding literal to the index that comes in, I could do: Select Case index Case 1 Literal1.Text = "new value" Case 2 Literal2.Text = "new value" Case 3 Literal3.Text = "new value" End Select But theres a lot more than 3 literals, how can I dynamically generate the object name that I want to manipulate? Thanks Quote
Administrators PlausiblyDamp Posted April 17, 2007 Administrators Posted April 17, 2007 You could use the FindControl method of the page to locate the correct control Don't have VS handy but the code would be something like dim l as Literal l = FindControl("Literal" & index.ToString()) l.Text = "New Value" Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.