Sunteți pe pagina 1din 20

SP.

NET Web Forms - The DataList Control Previous Next Chapter

The DataList control is, like the Repeater control, used to display a repeated list of items that are bound to the control. However, the DataList control adds a table around the data items by default. Bind a DataSet to a DataList Control

The DataList control is, like the Repeater control, used to display a repeated list of items that are bound to the control. However, the DataList control adds a table around the data items by default. The DataList control may be bound to a database table, an XML file, or another list of items. Here we will show how to bind an XML file to a DataList control.

We will use the following XML file in our examples ("cdcatalog.xml"): <?xml version="1.0" encoding="ISO-8859-1"?>

<catalog> <cd> <title>Empire Burlesque</title> <artist>Bob Dylan</artist> <country>USA</country> <company>Columbia</company> <price>10.90</price> <year>1985</year> </cd> <cd> <title>Hide your heart</title>

<artist>Bonnie Tyler</artist> <country>UK</country> <company>CBS Records</company> <price>9.90</price> <year>1988</year> </cd> <cd> <title>Greatest Hits</title> <artist>Dolly Parton</artist> <country>USA</country> <company>RCA</company> <price>9.90</price> <year>1982</year> </cd> <cd> <title>Still got the blues</title> <artist>Gary Moore</artist> <country>UK</country> <company>Virgin records</company> <price>10.20</price> <year>1990</year> </cd> <cd> <title>Eros</title> <artist>Eros Ramazzotti</artist>

<country>EU</country> <company>BMG</company> <price>9.90</price> <year>1997</year> </cd> </catalog>

Take a look at the XML file: cdcatalog.xml

First, import the "System.Data" namespace. We need this namespace to work with DataSet objects. Include the following directive at the top of an .aspx page: <%@ Import Namespace="System.Data" %>

Next, create a DataSet for the XML file and load the XML file into the DataSet when the page is first loaded: <script runat="server"> sub Page_Load if Not Page.IsPostBack then dim mycdcatalog=New DataSet mycdcatalog.ReadXml(MapPath("cdcatalog.xml")) end if end sub

Then we create a DataList in an .aspx page. The contents of the <HeaderTemplate> element are rendered first and only once within the output, then the contents of the <ItemTemplate> element are repeated for each "record" in the DataSet, and last, the contents of the <FooterTemplate> element are rendered once within the output:

<html> <body>

<form runat="server"> <asp:DataList id="cdcatalog" runat="server">

<HeaderTemplate> ... </HeaderTemplate>

<ItemTemplate> ... </ItemTemplate>

<FooterTemplate> ... </FooterTemplate>

</asp:DataList> </form>

</body> </html>

Then we add the script that creates the DataSet and binds the mycdcatalog DataSet to the DataList control. We also fill the DataList control with a <HeaderTemplate> that contains the header of the table,

an <ItemTemplate> that contains the data items to display, and a <FooterTemplate> that contains a text. Note that the gridlines attribute of the DataList is set to "both" to display table borders: Example <%@ Import Namespace="System.Data" %>

<script runat="server"> sub Page_Load if Not Page.IsPostBack then dim mycdcatalog=New DataSet mycdcatalog.ReadXml(MapPath("cdcatalog.xml")) cdcatalog.DataSource=mycdcatalog cdcatalog.DataBind() end if end sub </script>

<html> <body>

<form runat="server"> <asp:DataList id="cdcatalog" gridlines="both" runat="server">

<HeaderTemplate> My CD Catalog </HeaderTemplate>

<ItemTemplate> "<%#Container.DataItem("title")%>" of <%#Container.DataItem("artist")%> $<%#Container.DataItem("price")%> </ItemTemplate>

<FooterTemplate> Copyright Hege Refsnes </FooterTemplate>

</asp:DataList> </form>

</body> </html>

Show example Using Styles

You can also add styles to the DataList control to make the output more fancy: Example <%@ Import Namespace="System.Data" %>

<script runat="server">

sub Page_Load if Not Page.IsPostBack then dim mycdcatalog=New DataSet mycdcatalog.ReadXml(MapPath("cdcatalog.xml")) cdcatalog.DataSource=mycdcatalog cdcatalog.DataBind() end if end sub </script>

<html> <body>

<form runat="server"> <asp:DataList id="cdcatalog" runat="server" cellpadding="2" cellspacing="2" borderstyle="inset" backcolor="#e8e8e8" width="100%" headerstyle-font-name="Verdana" headerstyle-font-size="12pt" headerstyle-horizontalalign="center" headerstyle-font-bold="true"

itemstyle-backcolor="#778899" itemstyle-forecolor="#ffffff" footerstyle-font-size="9pt" footerstyle-font-italic="true">

<HeaderTemplate> My CD Catalog </HeaderTemplate>

<ItemTemplate> "<%#Container.DataItem("title")%>" of <%#Container.DataItem("artist")%> $<%#Container.DataItem("price")%> </ItemTemplate>

<FooterTemplate> Copyright Hege Refsnes </FooterTemplate>

</asp:DataList> </form>

</body> </html>

Show example Using the <AlternatingItemTemplate>

You can add an <AlternatingItemTemplate> element after the <ItemTemplate> element to describe the appearance of alternating rows of output. You may style the data in the <AlternatingItemTemplate> section within the DataList control: Example <%@ Import Namespace="System.Data" %>

<script runat="server"> sub Page_Load if Not Page.IsPostBack then dim mycdcatalog=New DataSet mycdcatalog.ReadXml(MapPath("cdcatalog.xml")) cdcatalog.DataSource=mycdcatalog cdcatalog.DataBind() end if end sub </script>

<html> <body>

<form runat="server"> <asp:DataList id="cdcatalog" runat="server"

cellpadding="2" cellspacing="2" borderstyle="inset" backcolor="#e8e8e8" width="100%" headerstyle-font-name="Verdana" headerstyle-font-size="12pt" headerstyle-horizontalalign="center" headerstyle-font-bold="True" itemstyle-backcolor="#778899" itemstyle-forecolor="#ffffff" alternatingitemstyle-backcolor="#e8e8e8" alternatingitemstyle-forecolor="#000000" footerstyle-font-size="9pt" footerstyle-font-italic="True">

<HeaderTemplate> My CD Catalog </HeaderTemplate>

<ItemTemplate> "<%#Container.DataItem("title")%>" of <%#Container.DataItem("artist")%> $<%#Container.DataItem("price")%> </ItemTemplate>

<AlternatingItemTemplate> "<%#Container.DataItem("title")%>" of <%#Container.DataItem("artist")%> $<%#Container.DataItem("price")%> </AlternatingItemTemplate>

<FooterTemplate> &copy; Hege Refsnes </FooterTemplate>

</asp:DataList> </form>

</body> </html>

vBulletin-Related Terms
Links from this section: Access Mask Admin Control Panel Administrator Avatar BB Code Buddy List Bulletin Board Category Conditionals Customer Number Customer Password Data APIs Forum Guest Hook Ignore List Inline Moderation Member Members' Area

Moderator Moderator Control Panel Plugin Post Post Icon Product Prune Replacement Variable Smilies Sticky Thread StyleVar Super Administrator Super Moderator Thread User User Control Panel Usergroup Manual Navigation Next: Access Mask Previous: Appendix: Terminology Up: Appendix: Terminology Page Top Search Home

vBulletin 5 Connect Template Syntax


vBulletin 5 Connect expands on the vBulletin Markup used in templates. These are the new methods you can use for manipulating and retrieving content from the API and Database.

New Built-in Methods


{vb:set}
{vb:set} is used for assigning template variables during the execution of a template.

Parameter Position 1 2
Code:

Parameter Name Type variable value string compilable code

Required Description Yes Yes The name of the variable being assigned The value being assigned

{vb:set name, 'Adrian'} The value of $name is {vb:raw name}.


The above example will output:

The value of $name is Adrian.

{vb:template}
{vb:template} is used for including other templates in the current template.

Parameter Position

Parameter Name Type

Required Description

1 2...
Template:

template [var=value]

string compilable code

Yes No

The name of the template to include Variable to pass local to template

This is {vb:raw arg1}. Today is {vb:raw arg2}


Code:

{vb:template template, arg1="an example", arg2="Sunday"}


The above example will output:

This is an example. Today is Sunday

{vb:js}
{vb:js} is used for including javascript files from filesystem easily before body close tag.

Parameter Position 1...


Code:

Parameter Name Type path[, ...] relative path

Required Description Yes Relative path of the javascript file to include

{vb:js js/test.js, js/test1.js}


The above example will output the following code before </body>:

<script type="text/javascript" src="http://localhost/vb5/js/test.js?v=500a36"></script> <script type="text/javascript" src="http://localhost/vb5/js/test1.js?v=500a36"></script>

{vb:cssextra}
{vb:cssextra} is used for including css templates easily before head close tag (all css templates are included in one request).

Parameter Position Parameter Name Type Required Description 1...


Code:

template[, ...]

string Yes

The name of the css template

{vb:cssextra test.css, test1.css}


The above example will output the following code before </head>:

<link rel="stylesheet" type="text/css" href="http://localhost/vb5/core/css.php?styleid=x&amp;td=xxx&amp;sheet=xxx.cs s,...,test.css,test1.csss?ts=xxxxxxxxxxx" />

{vb:hook}
{vb:hook} is used for including templates hooks in current template.

Parameter Position Parameter Name Type Required Description 1


Code:

hook

string Yes

The name of the template hook

{vb:hook test}

{vb:redirect}
{vb:redirect} is used for perfoming a php redirect during the execution of a template.

Parameter Position Parameter Name Type Required Description 1


Code:

url

url

Yes

The url of the page to redirect

{vb:redirect 'http://www.google.com.ar/'}

{vb:strcat}
{vb:strcat} is used for concatenating values to the given variable.

Parameter Position 1 2...


Code:

Parameter Name Type variable string[, ...] string compiable code

Required Description Yes No The name of the variable being assigned The value being concatenated

{vb:strcat test, 'This is a', ' test'} {vb:raw test}


The above example will output the following:

This is a test

{vb:strrepeat}
{vb:strrepeat} is used for repeating a string to the given variable.

Parameter

Parameter Name Type

Required Description

Position 1 2
Code:

input multiplier

variable Yes variable Yes

The string variable to be repeated The positive integer variable of time the input should be repeated

{vb:set input, '. '} {vb:set multipler, 10} {vb:strrepeat input {vb:raw multipler}} {vb:raw input}
The above example will output the following:

. . . . . . . . . .

{vb:data}
{vb:data} is used for setting an API class and method return value to the given variable.

Parameter Position 1 2 3 4...


Code:

Parameter Name Type variable controller method argument string string string compilable code

Required Description Yes Yes Yes No The name of the variable being assigned The name of the called controller The name of the called method Variable to pass to called method

{vb:data unread, content_privatemessage, getUnreadInboxCount} {vb:raw unread}


vB_Api_Content_Privatemessage->getUnreadInboxCount() The above example will output the count of undeleted notifications.

{vb:url}
{vb:url} is used for building an hyperlink url of the specified route.

Parameter Position 1

Parameter Name Type Required Description route string Yes The route identifier (routeid or name)

2 3 4
Code:

data extra options

array No array No array No

Data for building route Additional data to be added Options for building URL noBaseUrl: skips adding the baseurl

{vb:url 'lostpw'}
The above example will output the following:

http://localhost/vb5/lostpw

{vb:debugvardump}
{vb:debugvardump} is used for dumping information about a variable.

Parameter Position Parameter Name Type 1


Code:

Required Description The variable you want to dump

expression

variable Yes

{vb:debugvardump $user}
The above example will output the dump of user variable into a nice red box.

{vb:php}
{vb:php} is used to run allowed php functions during the execution of a template.

Parameter Position 1 2...


Code:

Parameter Name Type function name string[, ...] string compiable code

Required Description Yes No The name of the function Arguments of the function

{vb:set test, {vb:php implode, ',', {vb:raw variable}}}


PHP Equivalent:

<?php $test = implode(',', $variable);


Allowed functions:

implode() explode() array_merge()

array_intersect() array_intersect_key() array_keys() array_push() array_pop() array_shift() array_unshift() array_unique() array() current() str_repeat() str_pad() strip_tags() strtolower() strtoupper() trim() substr() vbstrtolower()
Manual Navigation Next: Scheduled Tasks Previous: Extensions Up: Developers Page Top Search Home

Managing Scheduled Tasks


Path to Scheduled Task Manager: Scheduled Tasks > Scheduled Task Manager <<<Insert a level-setting screenshot of Scheduled Task Manager.>>> The Scheduled Task Manager displays all the currently defined tasks and lets you modify them and add new tasks. The table has the following columns: Checkbox To disable a number of tasks at once, uncheck the chec kbox next to the tasks youd like to disable and click the [Save Enabled Status] button. To enable any disabled task, check the checkbox and click the [Save Enabled Status] button. m (Minute) The minute that a task runs. If this is an asterisk it runs every minute. h (Hour) The hour that a task runs. If this is an asterisk it runs every hour.

D (Day) The day of the month (numerically) that a task runs. If this is an asterisk it runs every day. M (Month) The month of the year that a task runs. If this is an asterisk it runs every month. DoW (Day of Week) The day of the week that a task runs. If this is an asterisk, it defers to the Day setting. Title The title of the scheduled task in bold with a short description of the task below. Next Time The next time the task is scheduled to run. You can run it immediately using the [Run Now] button on the far right. Controls This column contains a drop-down with Edit, Enable/Disable and Delete controls, and a [Run Now] button to run the task immediately. To edit the settings for a task, select Edit. This opens the Edit Scheduled Task form. To delete a task, select Delete. Manual Navigation

What's New in vBulletin 5.


vBulletin 5 has been designed to bring you modern community building and ease of use.

Site Builder
One of the best new features of vBulletin 5 Connect is Site Builder. Site Builder is a new way to build and manage your sites. It features drag and drop technology to enable you to build custom pages that fit your needs quickly and easily. Site Builder also includes a Style Generator so you can quickly and easily create a new styles with custom color combinations.

Everything is Content
In vBulletin 5, weve developed an idea that everything is content. This is built around a new content model involving channels, nodes and the actual content. In this model everything works the same, everything is searchable and everything provides a modern input system. Adding new content should be more intuitive for your users.

New Search
The Search Engine architecture has also been reconfigured so that all content is easily searched. Rewritten from the ground up, the new search engine should provide more relevant details and accurate results.

MVC Architecture
vBulletin 5 Connect introduces a new MVC Architecture designed to separate the business logic from the presentation logic more than ever before. This will allow vBulletin 5 to be quickly and easily extended as we bring new features to the software.

Responsive Design
People are using devices of many different sizes these days. These include phones, tablets and ultra-high density monitors. Weve included a responsive design in vBulletin 5 that scales to the device being used. No more worrying about mobile styles and trying to configure things for multiple devices. vBulletin adjusts to the screen-size of the users device automatically.

Expanded API
The API of vBulletin has been expanded. Not only can mobile apps take advantage of the API, the web interface of vBulletin uses it for its own purposes as well. This provides a more structured design and the ability to code everything once regardless of how it is accessed. M

System Requirements
Minimum Requirements vBulletin is a web-based application and as such has a few minimum requirements. To run vBulletin, you need a web hosting provider that includes the following things:

PHP version 5.3.0 or greater MySQL version 5.1.5 or greater A pre-registered domain name 1 Gigabyte of hard drive space Rewrite Engine A rewrite engine is needed for vBulletins Friendly URL routing to work. Popular rewrite
engines include mod_rewrite on Apache and URL Rewrite for IIS 7 or greater. Most hosting providers have already installed these applications on their servers. With the above requirements meant, the vBulletin software will run on any operating system using any modern web server software. Recommended Requirements The following settings and software packages are not required but will make your vBulletin experience more enjoyable. Your hosting provider can tell you whether these are available on your server.

MySQL 5.5 or greater. cURL or OpenSSL support Allows secure connections to third-party services like Facebook Connect. MySQLi support MySQLi is a more robust software library to connect to the database that vBulletin uses. Iconv support A library that provides extra language and character set support. OpCode Cache An OpCode Cache like APC or XCache will enhance the performance of your vBulletin
software. An OpCode Cache is a caching mechanism that can significantly increase the performance of vBulletin by pre-parsing the PHP files and keeping commonly used data in memory for rapid retrieval. Once you have a web hosting package meeting the minimum requirements, you are ready to proceed with vBulletin. For help in finding an appropriate web hosting company, please view our Hosting Options forum. Note: Please note that modern websites are driven heavily by media which takes space. The more hard drive space you can get with your hosting package the better for the growth of your community. Manual Navigation

BB Code
BB Codes, sometimes referred to as vB Codes, are a used to replace the need for html tags when formatting text in posts. Examples: In html to make text bold, italics or underlined you would use:

<b>Bold</b> <i>Italic</i> <u>Underlined</u>


With BB Code you use: [b]Bold[/b]

[i]Italic[/i] [u]Underlined[/u] Manual

S-ar putea să vă placă și