Repeater with Datalist - quick help needed for tomorrow's presentation

A

Axel

Hi,

I have found an article on Web User Controls in Repeaters with DataList

http://www.c-sharpcorner.com/UploadFile/Mike Clark/PartA02272007012412AM/PartA.aspx

, thanks very much.

I am currently trying to incorporate a web user control for generating
web content via a GenericList. I have managed to do all the coding for
all the detail, have a lovely web user control coded, but I am binding
to the Datasource in the Page_Load event of the container code:



private Product _Product;

if (_Product.hasMasterAttributes)
{
this.repeatAttributes.DataSource = _Product.masterAttributeList;
}

the Product class contains a Generic List of ProductAttribute class
instances. (ProductAttribute is a very simple class which just serves as
strongly typed container for my attributes).

I am exposing the various attributes of ProductAttribute (such as
ContentText, URL etc) as properties and also I have same public
properties in the Web User Control in order to marshall data from the
ProductAttribute instance to the Web User Control. What I am having real
difficulty with is the actual binding of these attributes within the
ItemTemplate, also I do not like using the server code on the asp page
(especially since I can not debug what is happening) - do you know if
it is possible to use an event for binding these?

<asp:Repeater ID="repeatAttributes" runat="server"
onitemdatabound="repeatAttributes_ItemDataBound"
onitemcreated="repeatAttributes_ItemCreated" >
<ItemTemplate >
<uc1:EditAttributePanel ID="theAttributePanel"
runat="server"


ContentTitle="<%#DataBinder.Eval(Container.DataItem,"ContentTitle")%>"
Language = "<%#DataBinder.Eval(Container.DataItem,"LanguageId")%>"
Attribute = "<%#DataBinder.Eval(Container.DataItem,"AttributeCount")%>"



/>
</ItemTemplate>
</asp:Repeater>

I had quite great toruble with the lines for copying data from the
container List to the properties of the Web User Control (see 3 lkinbes
above in the stripped down example above) lots of runtime compile
errors, and I don't really like that code polluting the aspx file. Also
now that the page is not crashing anymore, it doesn't show anything in
the Repeater, although my generic lists definitelyt contain data; where
can I check what data is being marshalled into the repeater?

I would prefer doing all the copying of data between List Item and web
control instance from code, which would give me more control and I could
add validation, is there an event I can use for this???

Another feature that my project provides is a localization interface so
the Product actually contains 2 Generic Lists of Attributes (one for the
Master Language and one for the current translation), which is another
reason that I would like to have the databinding in C# code and not on
the container page itself.

thanks in advance
Axel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,967
Messages
2,570,148
Members
46,694
Latest member
LetaCadwal

Latest Threads

Top