.NET Framework Class Library ListViewCancelEventArgs Class

Inheritance Hierarchy
Namespace:
System.Web.UI.WebControls
Assembly:
System.Web.Extensions (in System.Web.Extensions.dll)

Syntax
Public Class ListViewCancelEventArgs _
Inherits CancelEventArgs
public class ListViewCancelEventArgs : CancelEventArgs
public ref class ListViewCancelEventArgs : public CancelEventArgs
type ListViewCancelEventArgs =
class
inherit CancelEventArgs
end
The ListViewCancelEventArgs type exposes the following members.

Constructors

Methods

Remarks
The ListView control raises the ItemCanceling event when the Cancel button is clicked, but before exiting insert or edit mode. (A Cancel button is a button whose CommandName property is set to "Cancel") This enables you to provide an event-handling method that performs a custom routine whenever this event occurs, such as stopping the cancel operation if it would put the item in an unwanted state. A ListViewCancelEventArgs object is passed to the event-handling method. This object enables you to determine the index of the item that contains the Cancel button that raised the event. You can also determine what operation was canceled. To stop the cancel operation, set the Cancel property to true. For a list of initial property values for an instance of the ListViewCancelEventArgs class, see the ListViewCancelEventArgs constructor.

Examples
The following example shows how to use the ListViewCancelEventArgs object to display a message when the user cancels the insert or update operation in a ListView control. The ListViewCancelEventArgs object is passed to the event-handling method for the ItemCanceling event. Security Note |
|---|
This example contains a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview. |
<%@ Page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub Page_Load()
Message.Text = String.Empty
End Sub
Protected Sub ContactsListView_ItemCanceling(ByVal sender As Object, _
ByVal e As ListViewCancelEventArgs)
'Check the operation that raised the event
If (e.CancelMode = ListViewCancelMode.CancelingEdit) Then
' The update operation was canceled. Display the
' primary key of the item.
Message.Text = "Update for the ContactID " & _
ContactsListView.DataKeys(e.ItemIndex).Value.ToString() & " canceled."
Else
Message.Text = "Insert operation canceled."
End If
End Sub
Protected Sub ContactsListView_PagePropertiesChanging(ByVal sender As Object, _
ByVal e As PagePropertiesChangingEventArgs)
' Clears the edit index selection when paging.
ContactsListView.EditIndex = -1
End Sub
</script>
<html >
<head id="Head1" runat="server">
<title>ListView ItemCanceling Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>ListView ItemCanceling Example</h3>
<asp:Label ID="Message"
ForeColor="Red"
runat="server"/>
<br/>
<asp:ListView ID="ContactsListView"
DataSourceID="ContactsDataSource"
DataKeyNames="ContactID"
ConvertEmptyStringToNull="true"
InsertItemPosition="LastItem"
runat="server"
OnItemCanceling="ContactsListView_ItemCanceling"
OnPagePropertiesChanging="ContactsListView_PagePropertiesChanging" >
<LayoutTemplate>
<table cellpadding="2" width="680px" border="1" runat="server" id="tblContacts">
<tr runat="server">
<th runat="server"> </th>
<th runat="server">ID</th>
<th runat="server">First Name</th>
<th runat="server">Last Name</th>
<th runat="server">E-mail Address</th>
</tr>
<tr runat="server" id="itemPlaceholder" />
</table>
<asp:DataPager runat="server" ID="ContactsDataPager" PageSize="12">
<Fields>
<asp:NextPreviousPagerField
ShowFirstPageButton="true" ShowLastPageButton="true"
FirstPageText="|<< " LastPageText=" >>|"
NextPageText=" > " PreviousPageText=" < " />
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<tr runat="server">
<td valign="top">
<asp:LinkButton ID="EditButton" runat="server" Text="Edit" CommandName="Edit" /><br />
</td>
<td valign="top">
<asp:Label ID="Label1" runat="server" Text='<%#Eval("ContactID") %>' />
</td>
<td valign="top">
<asp:Label ID="FirstNameLabel" runat="server" Text='<%#Eval("FirstName") %>' />
</td>
<td valign="top">
<asp:Label ID="LastNameLabel" runat="server" Text='<%#Eval("LastName") %>' />
</td>
<td valign="top">
<asp:Label ID="EmailAddressLabel" runat="server" Text='<%#Eval("EmailAddress") %>' />
</td>
</tr>
</ItemTemplate>
<EditItemTemplate>
<tr style="background-color: #ADD8E6">
<td valign="top">
<asp:LinkButton ID="UpdateButton" runat="server" CommandName="Update" Text="Update" /><br />
<asp:LinkButton ID="CancelEditButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
<td>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("ContactID") %>' />
</td>
<td>
<asp:TextBox ID="FirstNameTextBox" runat="server"
Text='<%#Bind("FirstName") %>' MaxLength="50" /><br />
</td>
<td>
<asp:TextBox ID="LastNameTextBox" runat="server"
Text='<%#Bind("LastName") %>' MaxLength="50" /><br />
</td>
<td>
<asp:TextBox ID="EmailAddressTextBox" runat="server"
Text='<%#Bind("EmailAddress") %>' MaxLength="50" /><br />
</td>
</tr>
</EditItemTemplate>
<InsertItemTemplate>
<tr style="background-color:#90EE90">
<td colspan="2">
<asp:LinkButton ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" /><br />
<asp:LinkButton ID="CancelInsertButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
<td>
<asp:TextBox ID="FirstNameITextBox" runat="server"
Text='<%#Bind("FirstName") %>' MaxLength="50" />
</td>
<td>
<asp:TextBox ID="LastNameITextBox" runat="server"
Text='<%#Bind("LastName") %>' MaxLength="50" />
</td>
<td>
<asp:TextBox ID="EmailAddressITextBox" runat="server"
Text='<%#Bind("EmailAddress") %>' MaxLength="50" />
</td>
</tr>
</InsertItemTemplate>
</asp:ListView>
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the AdventureWorks sample database. Use an ASP.NET -->
<!-- expression to retrieve the connection string value -->
<!-- from the Web.config file. -->
<asp:SqlDataSource ID="ContactsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
SelectCommand="SELECT [ContactID], [FirstName], [LastName], [EmailAddress] FROM Person.Contact"
InsertCommand="INSERT INTO Person.Contact
([FirstName], [LastName], [EmailAddress], [PasswordHash], [PasswordSalt])
Values(@FirstName, @LastName, @EmailAddress, '', '')"
UpdateCommand="UPDATE Person.Contact
SET FirstName = @FirstName, LastName = @LastName,
EmailAddress = @EmailAddress
WHERE ContactID = @ContactID">
</asp:SqlDataSource>
</form>
</body>
</html>
<%@ Page language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void Page_Load()
{
Message.Text = String.Empty;
}
protected void ContactsListView_ItemCanceling(object sender, ListViewCancelEventArgs e)
{
//Check the operation that raised the event
if (e.CancelMode == ListViewCancelMode.CancelingEdit)
{
// The update operation was canceled. Display the
// primary key of the item.
Message.Text = "Update for the ContactID " +
ContactsListView.DataKeys[e.ItemIndex].Value.ToString() + " canceled.";
}
else
{
Message.Text = "Insert operation canceled.";
}
}
protected void ContactsListView_PagePropertiesChanging(object sender,
PagePropertiesChangingEventArgs e)
{
// Clears the edit index selection when paging.
ContactsListView.EditIndex = -1;
}
</script>
<html >
<head id="Head1" runat="server">
<title>ListView ItemCanceling Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>ListView ItemCanceling Example</h3>
<asp:Label ID="Message"
ForeColor="Red"
runat="server"/>
<br/>
<asp:ListView ID="ContactsListView"
DataSourceID="ContactsDataSource"
DataKeyNames="ContactID"
ConvertEmptyStringToNull="true"
InsertItemPosition="LastItem"
runat="server"
OnItemCanceling="ContactsListView_ItemCanceling"
OnPagePropertiesChanging="ContactsListView_PagePropertiesChanging" >
<LayoutTemplate>
<table cellpadding="2" width="680px" border="1" runat="server" id="tblContacts">
<tr runat="server">
<th runat="server"> </th>
<th runat="server">ID</th>
<th runat="server">First Name</th>
<th runat="server">Last Name</th>
<th runat="server">E-mail Address</th>
</tr>
<tr runat="server" id="itemPlaceholder" />
</table>
<asp:DataPager runat="server" ID="ContactsDataPager" PageSize="12">
<Fields>
<asp:NextPreviousPagerField
ShowFirstPageButton="true" ShowLastPageButton="true"
FirstPageText="|<< " LastPageText=" >>|"
NextPageText=" > " PreviousPageText=" < " />
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<tr runat="server">
<td valign="top">
<asp:LinkButton ID="EditButton" runat="server" Text="Edit" CommandName="Edit" /><br />
</td>
<td valign="top">
<asp:Label ID="Label1" runat="server" Text='<%#Eval("ContactID") %>' />
</td>
<td valign="top">
<asp:Label ID="FirstNameLabel" runat="server" Text='<%#Eval("FirstName") %>' />
</td>
<td valign="top">
<asp:Label ID="LastNameLabel" runat="server" Text='<%#Eval("LastName") %>' />
</td>
<td valign="top">
<asp:Label ID="EmailAddressLabel" runat="server" Text='<%#Eval("EmailAddress") %>' />
</td>
</tr>
</ItemTemplate>
<EditItemTemplate>
<tr style="background-color: #ADD8E6">
<td valign="top">
<asp:LinkButton ID="UpdateButton" runat="server" CommandName="Update" Text="Update" /><br />
<asp:LinkButton ID="CancelEditButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
<td>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("ContactID") %>' />
</td>
<td>
<asp:TextBox ID="FirstNameTextBox" runat="server"
Text='<%#Bind("FirstName") %>' MaxLength="50" /><br />
</td>
<td>
<asp:TextBox ID="LastNameTextBox" runat="server"
Text='<%#Bind("LastName") %>' MaxLength="50" /><br />
</td>
<td>
<asp:TextBox ID="EmailAddressTextBox" runat="server"
Text='<%#Bind("EmailAddress") %>' MaxLength="50" /><br />
</td>
</tr>
</EditItemTemplate>
<InsertItemTemplate>
<tr style="background-color:#90EE90">
<td colspan="2">
<asp:LinkButton ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" /><br />
<asp:LinkButton ID="CancelInsertButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
<td>
<asp:TextBox ID="FirstNameITextBox" runat="server"
Text='<%#Bind("FirstName") %>' MaxLength="50" />
</td>
<td>
<asp:TextBox ID="LastNameITextBox" runat="server"
Text='<%#Bind("LastName") %>' MaxLength="50" />
</td>
<td>
<asp:TextBox ID="EmailAddressITextBox" runat="server"
Text='<%#Bind("EmailAddress") %>' MaxLength="50" />
</td>
</tr>
</InsertItemTemplate>
</asp:ListView>
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the AdventureWorks sample database. Use an ASP.NET -->
<!-- expression to retrieve the connection string value -->
<!-- from the Web.config file. -->
<asp:SqlDataSource ID="ContactsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
SelectCommand="SELECT [ContactID], [FirstName], [LastName], [EmailAddress] FROM Person.Contact"
InsertCommand="INSERT INTO Person.Contact
([FirstName], [LastName], [EmailAddress], [PasswordHash], [PasswordSalt])
Values(@FirstName, @LastName, @EmailAddress, '', '')"
UpdateCommand="UPDATE Person.Contact
SET FirstName = @FirstName, LastName = @LastName,
EmailAddress = @EmailAddress
WHERE ContactID = @ContactID">
</asp:SqlDataSource>
</form>
</body>
</html>

Version Information
.NET FrameworkSupported in: 4, 3.5

Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Thread Safety
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also
|
Bibliothèque de classes .NET Framework ListViewCancelEventArgs, classe

Hiérarchie d'héritage
Espace de noms :
System.Web.UI.WebControls
Assembly :
System.Web.Extensions (dans System.Web.Extensions.dll)

Syntaxe
Public Class ListViewCancelEventArgs _
Inherits CancelEventArgs
public class ListViewCancelEventArgs : CancelEventArgs
public ref class ListViewCancelEventArgs : public CancelEventArgs
type ListViewCancelEventArgs =
class
inherit CancelEventArgs
end
Le type ListViewCancelEventArgs expose les membres suivants.

Constructeurs

Méthodes

Notes
Le contrôle ListView déclenche l'événement ItemCanceling lorsque l'utilisateur clique sur le bouton Annuler, avant la fermeture des modes insertion et édition. (Le bouton Annuler est un bouton dont la propriété CommandName a la valeur « Cancel ».) Cela vous permet de fournir une méthode de gestion d'événements qui exécute une routine personnalisée chaque fois que cet événement se produit, par exemple l'arrêt de l'opération d'annulation si cette dernière affecte à l'élément un état non désiré. Un objet ListViewCancelEventArgs est passé à la méthode de gestion d'événements. Cet objet vous permet de déterminer l'index de l'élément qui contient le bouton Annuler qui a déclenché l'événement. Vous pouvez également déterminer l'opération qui a été annulée. Pour arrêter l'opération d'annulation, affectez true à la propriété Cancel. Pour obtenir la liste des valeurs initiales des propriétés d'une instance de la classe ListViewCancelEventArgs, consultez le constructeur ListViewCancelEventArgs.

Exemples
L'exemple suivant indique comment utiliser l'objet ListViewCancelEventArgs pour afficher un message lorsque l'utilisateur annule les opérations d'insertion ou de mise à jour dans un contrôle ListView. L'objet ListViewCancelEventArgs est passé à la méthode de gestion d'événements pour l'événement ItemCanceling. Note de sécurité |
|---|
Cet exemple comporte une zone de texte qui accepte l'entrée d'utilisateur, ce qui constitue une menace éventuelle pour la sécurité. Par défaut, les pages Web ASP.NET vérifient que l'entrée d'utilisateur n'inclut pas de script ni d'éléments HTML. Pour plus d'informations, consultez Vue d'ensemble des attaques de script. |
<%@ Page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub Page_Load()
Message.Text = String.Empty
End Sub
Protected Sub ContactsListView_ItemCanceling(ByVal sender As Object, _
ByVal e As ListViewCancelEventArgs)
'Check the operation that raised the event
If (e.CancelMode = ListViewCancelMode.CancelingEdit) Then
' The update operation was canceled. Display the
' primary key of the item.
Message.Text = "Update for the ContactID " & _
ContactsListView.DataKeys(e.ItemIndex).Value.ToString() & " canceled."
Else
Message.Text = "Insert operation canceled."
End If
End Sub
Protected Sub ContactsListView_PagePropertiesChanging(ByVal sender As Object, _
ByVal e As PagePropertiesChangingEventArgs)
' Clears the edit index selection when paging.
ContactsListView.EditIndex = -1
End Sub
</script>
<html >
<head id="Head1" runat="server">
<title>ListView ItemCanceling Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>ListView ItemCanceling Example</h3>
<asp:Label ID="Message"
ForeColor="Red"
runat="server"/>
<br/>
<asp:ListView ID="ContactsListView"
DataSourceID="ContactsDataSource"
DataKeyNames="ContactID"
ConvertEmptyStringToNull="true"
InsertItemPosition="LastItem"
runat="server"
OnItemCanceling="ContactsListView_ItemCanceling"
OnPagePropertiesChanging="ContactsListView_PagePropertiesChanging" >
<LayoutTemplate>
<table cellpadding="2" width="680px" border="1" runat="server" id="tblContacts">
<tr runat="server">
<th runat="server"> </th>
<th runat="server">ID</th>
<th runat="server">First Name</th>
<th runat="server">Last Name</th>
<th runat="server">E-mail Address</th>
</tr>
<tr runat="server" id="itemPlaceholder" />
</table>
<asp:DataPager runat="server" ID="ContactsDataPager" PageSize="12">
<Fields>
<asp:NextPreviousPagerField
ShowFirstPageButton="true" ShowLastPageButton="true"
FirstPageText="|<< " LastPageText=" >>|"
NextPageText=" > " PreviousPageText=" < " />
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<tr runat="server">
<td valign="top">
<asp:LinkButton ID="EditButton" runat="server" Text="Edit" CommandName="Edit" /><br />
</td>
<td valign="top">
<asp:Label ID="Label1" runat="server" Text='<%#Eval("ContactID") %>' />
</td>
<td valign="top">
<asp:Label ID="FirstNameLabel" runat="server" Text='<%#Eval("FirstName") %>' />
</td>
<td valign="top">
<asp:Label ID="LastNameLabel" runat="server" Text='<%#Eval("LastName") %>' />
</td>
<td valign="top">
<asp:Label ID="EmailAddressLabel" runat="server" Text='<%#Eval("EmailAddress") %>' />
</td>
</tr>
</ItemTemplate>
<EditItemTemplate>
<tr style="background-color: #ADD8E6">
<td valign="top">
<asp:LinkButton ID="UpdateButton" runat="server" CommandName="Update" Text="Update" /><br />
<asp:LinkButton ID="CancelEditButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
<td>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("ContactID") %>' />
</td>
<td>
<asp:TextBox ID="FirstNameTextBox" runat="server"
Text='<%#Bind("FirstName") %>' MaxLength="50" /><br />
</td>
<td>
<asp:TextBox ID="LastNameTextBox" runat="server"
Text='<%#Bind("LastName") %>' MaxLength="50" /><br />
</td>
<td>
<asp:TextBox ID="EmailAddressTextBox" runat="server"
Text='<%#Bind("EmailAddress") %>' MaxLength="50" /><br />
</td>
</tr>
</EditItemTemplate>
<InsertItemTemplate>
<tr style="background-color:#90EE90">
<td colspan="2">
<asp:LinkButton ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" /><br />
<asp:LinkButton ID="CancelInsertButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
<td>
<asp:TextBox ID="FirstNameITextBox" runat="server"
Text='<%#Bind("FirstName") %>' MaxLength="50" />
</td>
<td>
<asp:TextBox ID="LastNameITextBox" runat="server"
Text='<%#Bind("LastName") %>' MaxLength="50" />
</td>
<td>
<asp:TextBox ID="EmailAddressITextBox" runat="server"
Text='<%#Bind("EmailAddress") %>' MaxLength="50" />
</td>
</tr>
</InsertItemTemplate>
</asp:ListView>
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the AdventureWorks sample database. Use an ASP.NET -->
<!-- expression to retrieve the connection string value -->
<!-- from the Web.config file. -->
<asp:SqlDataSource ID="ContactsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
SelectCommand="SELECT [ContactID], [FirstName], [LastName], [EmailAddress] FROM Person.Contact"
InsertCommand="INSERT INTO Person.Contact
([FirstName], [LastName], [EmailAddress], [PasswordHash], [PasswordSalt])
Values(@FirstName, @LastName, @EmailAddress, '', '')"
UpdateCommand="UPDATE Person.Contact
SET FirstName = @FirstName, LastName = @LastName,
EmailAddress = @EmailAddress
WHERE ContactID = @ContactID">
</asp:SqlDataSource>
</form>
</body>
</html>
<%@ Page language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void Page_Load()
{
Message.Text = String.Empty;
}
protected void ContactsListView_ItemCanceling(object sender, ListViewCancelEventArgs e)
{
//Check the operation that raised the event
if (e.CancelMode == ListViewCancelMode.CancelingEdit)
{
// The update operation was canceled. Display the
// primary key of the item.
Message.Text = "Update for the ContactID " +
ContactsListView.DataKeys[e.ItemIndex].Value.ToString() + " canceled.";
}
else
{
Message.Text = "Insert operation canceled.";
}
}
protected void ContactsListView_PagePropertiesChanging(object sender,
PagePropertiesChangingEventArgs e)
{
// Clears the edit index selection when paging.
ContactsListView.EditIndex = -1;
}
</script>
<html >
<head id="Head1" runat="server">
<title>ListView ItemCanceling Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>ListView ItemCanceling Example</h3>
<asp:Label ID="Message"
ForeColor="Red"
runat="server"/>
<br/>
<asp:ListView ID="ContactsListView"
DataSourceID="ContactsDataSource"
DataKeyNames="ContactID"
ConvertEmptyStringToNull="true"
InsertItemPosition="LastItem"
runat="server"
OnItemCanceling="ContactsListView_ItemCanceling"
OnPagePropertiesChanging="ContactsListView_PagePropertiesChanging" >
<LayoutTemplate>
<table cellpadding="2" width="680px" border="1" runat="server" id="tblContacts">
<tr runat="server">
<th runat="server"> </th>
<th runat="server">ID</th>
<th runat="server">First Name</th>
<th runat="server">Last Name</th>
<th runat="server">E-mail Address</th>
</tr>
<tr runat="server" id="itemPlaceholder" />
</table>
<asp:DataPager runat="server" ID="ContactsDataPager" PageSize="12">
<Fields>
<asp:NextPreviousPagerField
ShowFirstPageButton="true" ShowLastPageButton="true"
FirstPageText="|<< " LastPageText=" >>|"
NextPageText=" > " PreviousPageText=" < " />
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<tr runat="server">
<td valign="top">
<asp:LinkButton ID="EditButton" runat="server" Text="Edit" CommandName="Edit" /><br />
</td>
<td valign="top">
<asp:Label ID="Label1" runat="server" Text='<%#Eval("ContactID") %>' />
</td>
<td valign="top">
<asp:Label ID="FirstNameLabel" runat="server" Text='<%#Eval("FirstName") %>' />
</td>
<td valign="top">
<asp:Label ID="LastNameLabel" runat="server" Text='<%#Eval("LastName") %>' />
</td>
<td valign="top">
<asp:Label ID="EmailAddressLabel" runat="server" Text='<%#Eval("EmailAddress") %>' />
</td>
</tr>
</ItemTemplate>
<EditItemTemplate>
<tr style="background-color: #ADD8E6">
<td valign="top">
<asp:LinkButton ID="UpdateButton" runat="server" CommandName="Update" Text="Update" /><br />
<asp:LinkButton ID="CancelEditButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
<td>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("ContactID") %>' />
</td>
<td>
<asp:TextBox ID="FirstNameTextBox" runat="server"
Text='<%#Bind("FirstName") %>' MaxLength="50" /><br />
</td>
<td>
<asp:TextBox ID="LastNameTextBox" runat="server"
Text='<%#Bind("LastName") %>' MaxLength="50" /><br />
</td>
<td>
<asp:TextBox ID="EmailAddressTextBox" runat="server"
Text='<%#Bind("EmailAddress") %>' MaxLength="50" /><br />
</td>
</tr>
</EditItemTemplate>
<InsertItemTemplate>
<tr style="background-color:#90EE90">
<td colspan="2">
<asp:LinkButton ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" /><br />
<asp:LinkButton ID="CancelInsertButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
<td>
<asp:TextBox ID="FirstNameITextBox" runat="server"
Text='<%#Bind("FirstName") %>' MaxLength="50" />
</td>
<td>
<asp:TextBox ID="LastNameITextBox" runat="server"
Text='<%#Bind("LastName") %>' MaxLength="50" />
</td>
<td>
<asp:TextBox ID="EmailAddressITextBox" runat="server"
Text='<%#Bind("EmailAddress") %>' MaxLength="50" />
</td>
</tr>
</InsertItemTemplate>
</asp:ListView>
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the AdventureWorks sample database. Use an ASP.NET -->
<!-- expression to retrieve the connection string value -->
<!-- from the Web.config file. -->
<asp:SqlDataSource ID="ContactsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
SelectCommand="SELECT [ContactID], [FirstName], [LastName], [EmailAddress] FROM Person.Contact"
InsertCommand="INSERT INTO Person.Contact
([FirstName], [LastName], [EmailAddress], [PasswordHash], [PasswordSalt])
Values(@FirstName, @LastName, @EmailAddress, '', '')"
UpdateCommand="UPDATE Person.Contact
SET FirstName = @FirstName, LastName = @LastName,
EmailAddress = @EmailAddress
WHERE ContactID = @ContactID">
</asp:SqlDataSource>
</form>
</body>
</html>

Informations de version
.NET FrameworkPris en charge dans : 4, 3.5

Plateformes
Windows 7, Windows Vista SP1 ou ultérieur, Windows XP SP3, Windows Server 2008 (installation minimale non prise en charge), Windows Server 2008 R2 (installation minimale prise en charge avec SP1 ou version ultérieure), Windows Server 2003 SP2
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.

Sécurité des threads
Tous les membres static ( Shared en Visual Basic) publics de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.

Voir aussi
RéférenceAutres ressources
|