asp.net.ph

DataList.EditItemTemplate Property

System.Web.UI.WebControls Namespace   DataList Class


Specifies the template to use for the item to edit in a DataList.

Syntax

<asp:datalist ... >

   <edititemtemplate>
      ... template definition here
   </edititemtemplate>

</asp:datalist>

Property Value

An ITemplate interface that defines how the item selected for editing in the DataList control is rendered.

The property is read/write with no default value.

Remarks

Use the EditItemTemplate to define the appearance of the item selected for editing in a DataList control.

The EditItemTemplate functions in the same way as the ItemTemplate, but rendered only for the row selected for editing in the DataList control. You can set the appearance for the item in this template using the EditItemStyle property.

To specify a template for the item to edit in a DataList, declare an <EditItemTemplate> element between the opening and closing tags of the control. You can then list the contents of the template between the opening and closing <EditItemTemplate> ... </EditItemTemplate> tags.

The item in the EditItemTemplate is data-bound. To display data in the EditItemTemplate, declare one or more Web server controls and set their data-binding expressions to evaluate to a field in the DataList control's DataSource.

Contact: <asp:textbox id = "contact" runat = "server" 
   text='<%# ( ( DataRowView ) Container.DataItem ) [ "ContactName" ] %>' />

For more information, see DataBinding Expression Syntax.

Example

The following example illustrates using the EditItemTemplate to display the item to edit in a DataList in a different layout and format.

<asp:datalist ... 
   edititemstyle-backcolor = "lightsteelblue">

   <itemtemplate>
      ... template definition here
   </itemtemplate>

   <edititemtemplate>

      <table ... >
      ...
      <tr>
         <td>Contact: </td>
         <td><asp:textbox id = "contact" runat = "server" 
            text='<%# ( ( DataRowView ) Container.DataItem ) [ "ContactName" ] %>' /></td>
      </tr>
      ...
      <tr align = "center">
         <td colspan=2>
            <asp:linkbutton commandname = "update" runat = "server" text = "Update" />
            <asp:linkbutton commandname = "cancel" runat = "server" text = "Cancel" />
         </td>
      </tr>
      </table>

   </edititemtemplate>

</asp:datalist>

 Show me 

See Also

DataList Members   EditItemIndex   EditItemStyle   Allowing Users to Edit Items in a DataList Control Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph