Work with Collections in asp.net

  • Thread starter Thread starter Øyvind Isaksen
  • Start date Start date
Ø

Øyvind Isaksen

Hello,

I have made a collection that holds all article attributes.
When I bind this collection to a datagrid, I get this result:



TemplateDefinitionName ArticleId Content
TemplateDefinitionId
-------------------------------------------------------------------------------------------------
Title 1 Here is title
text 1
Ingress 1 Here is ingress
text 2
Body 1 Here is body text
3


How is it possible to bind different content from this collection do
different controls (ex: textboxes)?
For example, I would like to say: "bind the Title content to txtTitle", or
"bind the Body content to txtBody".


Here is my code so far:


ArticleHandler ArticleHandler = new ArticleHandler();
ArticleAttributeCollection AttributeCollection =
ArticleHandler.GetArtricleAttributes(articleId);

//This writes out "Here is title text":
Response.Write(AttributeCollection[0].Content.ToString());

this.Test.DataSource = AttributeCollection;
this.Test.DataBind();


Instead of writing AttributeCollection[0].Content.ToString() to get the
Title Content, I would like a code that writes out the Content based on the
TemplatedefinitionName.
Like: AttributeCollection["Title"].Content.ToString() gives me "Here is
title text".


Possible? How??
 
Hi,

You cannot bind a list to a control that gets an unique value (like
Textbox).

You have to select the row you want to edit first
 
Back
Top