Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Need to build a repeater purely in code

Reply
Thread Tools

Need to build a repeater purely in code

 
 
Cappy
Guest
Posts: n/a
 
      02-02-2004
Hi.

I need help adding a repeater to my custom control in code.

I have created a custom control that draws a html panel to the screen.

I want to add a menu in the panel which will basically be a repeater
reading from an xml file.

so far I have this

protected override void CreateChildControls()
{
//Clear control state
Controls.Clear();

//make sure file name has been provided

//get data from xml file
//map the path to the menu xml file
string filePath = HttpContext.Current.Request.MapPath(_menufilePath) ;

//read xml file into DS
DataSet MenuDS = new DataSet();
MenuDS.ReadXml(filePath);

//create a new Repeater control and assign its
//data source
Repeater r = new Repeater();
r.DataSource = MenuDS;

//Stuck here
//How do I define my template and bind data to it

r.DataBind();

//add the Repeater control to the collection
Controls.Add(r);

//indicate that we have created child controls
ChildControlsCreated=true;
}


The above code works fine.. but now I need to know how to hard code
the template for the repeater and how to bind the data to it.

Can anyone help?

The xml file contains the following structure
<MenuItems>
<Item>
<Name>Homepage</Name>
<URL>/index.aspx</URL>
<Alt>Return to homepage</Alt>
<Image>/images/navLocationOff.jpg</Image>
<MouseOver>/images/navLocationOn.jpg</MouseOver>
</Item>
<Item>
<Name>NextLink</Name>
<URL>/index.aspx</URL>
<Alt>Go somewhere else</Alt>
<Image>/images/navLocationOff.jpg</Image>
<MouseOver>/images/navLocationOn.jpg</MouseOver>
</Item>
</MenuItems>

Thanks
Amit
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Do programming jobs exist that are purely online? Dot net work ASP .Net 1 01-03-2005 03:35 PM
Purely static build of Ruby rcoder@gmail.com Ruby 12 09-30-2004 04:14 PM
SWsoft Acronis Disk Director Suite 9.0 Build 508, Acronis OS Selector 8.0 Build 917, Acronis Partition Expert 2003 Build 292, Acronis Power Utilities 2004 Build 502, F-SECURE.ANTI vIRUS.PROXY v1.10.17.WINALL, F-SECURE.ANTI vIRUS v5.50.10260 for CITRI vvcd Computer Support 0 09-25-2004 01:38 AM
Purely emotional perspective Jeffrey Froman Python 12 08-11-2004 02:29 PM
Internal Structure of the DIR ommand of MS-DOS purely for a floppy drive media Anil Kumar Narayanan C++ 1 12-18-2003 12:05 PM



Advertisments