.NET Samples - ASP.NET Data Customization

This section includes the following samples:

Datalist2 Sample

DataList1 Sample

Datalist3 Sample

Datalist8 Sample

Datalist7 Sample

Datalist6 Sample

Datalist5 Sample

Datalist4 Sample

Datalist2 Sample

This sample demonstrates the use of the DataList control. Note that the look of the data items has been changed from the previous DataList1 example, simply by changing the contents of the control's ItemTemplate property. The RepeatDirection and RepeatColumns properties determine how the ItemTemplates are laid out.

Namespaces used in this sample:

System.Data; System; System.Data.SqlClient

Classes used in this sample:

Binder; Container; DataList; DataBinder; DataSet; SqlConnection; DataAdapter; Import; SqlDataAdapter; Page; Publish; Object; EventArgs; Publisher; Table

DataList1 Sample

This sample demonstrates a Repeater control bound to a DataView (returned from an SQL query). HeaderTemplate and FooterTemplate have also been defined and render at the beginning and end of the list, respectively.

Namespaces used in this sample:

System.Data; System; System.Data.SqlClient

Classes used in this sample:

Binder; Repeater; Container; DataBinder; Header; DataSet; SqlConnection; DataAdapter; Import; SqlDataAdapter; Page; Publish; Type; Object; EventArgs; Publisher; Table

Datalist3 Sample

This sample further demonstrates the flexibility of templates by changing the ItemTemplate again. This time, one of the DataItem values has been substituted for the src attribute of an <img> tag. The format String parameter of DataBinder.Eval has also been used to substitute a DataItem value in the query string for a URL.

Namespaces used in this sample:

System.Data; System; System.Data.SqlClient

Classes used in this sample:

Container; Binder; DataBinder; DataList; SqlDataAdapter; DataSet; SqlConnection; DataAdapter; Import; EventArgs; Object; Page; String; Publish; Publisher; Table; Message

Datalist8 Sample

This sample demonstrates how to get a reference to a specific child control in a DataList, using its Items collection to retrieve a DataListItem and calling the FindControl method on that object.

Namespaces used in this sample:

System.Data; System; System.Data.SqlClient

Classes used in this sample:

DataList; Binder; Container; DataBinder; Page; Object; SqlConnection; DataAdapter; EventArgs; Import; String; Message; SqlDataAdapter; DataSet; CheckBox; Publish; Table; Control; Publisher

Datalist7 Sample

This sample shows how to use an EditItemTemplate to customize the user interface for an editable item in the DataList control.

Namespaces used in this sample:

System.Data; System; System.Data.SqlClient

Classes used in this sample:

DataList; DataBinder; Container; Binder; Object; EventArgs; DataListCommandEventArgs; CommandEventArgs; Page; Publish; SqlConnection; Import; SqlDataAdapter; Message; DataSet; Publisher; DataAdapter; String; Table; Control; HtmlInputText

Datalist6 Sample

This sample shows how to use a SelectedItemTemplate to customize the user interface for a selected item in the DataList control.

Namespaces used in this sample:

System.Data; System; System.Data.SqlClient

Classes used in this sample:

DataList; String; Binder; Container; DataBinder; Message; SqlDataAdapter; DataAdapter; DataSet; Object; EventArgs; Label; SqlConnection; Import; Image; Page; Table; Type; Publish; Publisher; HyperLink; DataListCommandEventArgs; LinkButton; DataRowView; CommandEventArgs; Button; Url; Font; DataRow

Datalist5 Sample

This sample demonstrates raising arbitrary event commands. Note that while the DataList recognizes a few special commands such as Select and Edit/Update/Cancel, the command string raised inside a template can be any arbitrary string. For all commands, the DataList control's OnItemCommand method raises an ItemCommand event.

Namespaces used in this sample:

System.Data; System; System.Data.SqlClient

Classes used in this sample:

DataList; String; Container; DataBinder; Binder; Message; DataSet; SqlDataAdapter; DataAdapter; Label; Object; EventArgs; SqlConnection; Import; Image; Page; Table; Type; Publish; Publisher; DataRowView; CommandEventArgs; DataRow; Url; HyperLink; DataListCommandEventArgs

Datalist4 Sample

This sample demonstrates how to handle postback events from a templated control. In this sample, a button raises a Select command, calling a delegate method assigned to the DataList control's OnSelectedIndexChanged event.

Namespaces used in this sample:

System.Data; System; System.Data.SqlClient

Classes used in this sample:

DataList; String; Container; DataBinder; Binder; SqlDataAdapter; DataSet; DataAdapter; Object; SqlConnection; EventArgs; Import; Image; Page; Table; Message; Publish; Publisher; Type; DataRow; DataRowView