Ø
Øyvind Isaksen
I have a Repeater that dynamicly displayes some textboxes. Each Textbox has
an ID like this (example): ID="10_20_textbox". The first number (10)
describes what article this field is for, and the secound number (20)
describes what article attribute this belongs to. In my code I need to loop
through all the Items in my Repeater Control.
My question is: Is it possible to use "FindControl" when the ID is
dynamically generated (find part of ID, like "_textbox" in my example)? I
need to loop througt all controls in my repeater, and get the text,
ArticleID and ArticleAttributeID and add this to my collection.
Here is my code:
foreach (RepeaterItem Item in this.repAttributes.Items)
{
int varArticleID = Item.FindControl..?... Find TextBox ID, Split and get
the first number before "_"...
int varAttributeID = Item.FindControl..?... Find TextBox ID, Split and
get the secound number after "_"...
string varContent = item.FindControl..?... Find the Text value for this
textbox...
ArticleAttribute.ArticleId = varArticle
ArticleAttribute.ArticleAttribute = varAttributeID
ArticleAttribute.Content = varContent
ArticleAttributeCollection.Add(ArticleAttribute)
}
SaveAttributes(ArticleAttributeCollection)
an ID like this (example): ID="10_20_textbox". The first number (10)
describes what article this field is for, and the secound number (20)
describes what article attribute this belongs to. In my code I need to loop
through all the Items in my Repeater Control.
My question is: Is it possible to use "FindControl" when the ID is
dynamically generated (find part of ID, like "_textbox" in my example)? I
need to loop througt all controls in my repeater, and get the text,
ArticleID and ArticleAttributeID and add this to my collection.
Here is my code:
foreach (RepeaterItem Item in this.repAttributes.Items)
{
int varArticleID = Item.FindControl..?... Find TextBox ID, Split and get
the first number before "_"...
int varAttributeID = Item.FindControl..?... Find TextBox ID, Split and
get the secound number after "_"...
string varContent = item.FindControl..?... Find the Text value for this
textbox...
ArticleAttribute.ArticleId = varArticle
ArticleAttribute.ArticleAttribute = varAttributeID
ArticleAttribute.Content = varContent
ArticleAttributeCollection.Add(ArticleAttribute)
}
SaveAttributes(ArticleAttributeCollection)