.NET Framework Class Library ListViewEditEventArgs Class

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

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

Constructors

Methods

Remarks
The ListView control raises the ItemEditing event when an Edit button is clicked, but before the ListView item enters edit mode. (An Edit button is a button whose CommandName property set to "Edit".) This enables you to provide an event-handling method that performs a custom routine whenever this event occurs, such as canceling the edit operation. A ListViewEditEventArgs object is passed to the event-handling method. This object enables you to determine the index of the item that is being edited, and to indicate that the edit operation should be canceled. To cancel the edit operation, set the Cancel property of the ListViewEditEventArgs object to true. For a list of initial property values for an instance of ListViewEditEventArgs, see the ListViewEditEventArgs constructor.

Examples
The following example shows how to use the ListViewEditEventArgs object to cancel the edit operation when the user tries to update a discontinued item. Security Note |
|---|
This example has 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
Sub ProductsListView_ItemEditing(ByVal sender As Object, ByVal e As ListViewEditEventArgs)
Dim item As ListViewItem = ProductsListView.Items(e.NewEditIndex)
Dim dateLabel As Label = CType(item.FindControl("DiscontinuedDateLabel"), Label)
If String.IsNullOrEmpty(dateLabel.Text) Then _
Return
'Verify if the item is discontinued.
Dim discontinuedDate As DateTime = DateTime.Parse(dateLabel.Text)
If discontinuedDate < DateTime.Now Then
Message.Text = "You cannot edit a discontinued item."
e.Cancel = True
ProductsListView.SelectedIndex = -1
End If
End Sub
Sub DiscontinuedDateCalendar_OnSelectionChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim dateTextBox As TextBox = _
CType(ProductsListView.EditItem.FindControl("DiscontinuedDateTextBox"), TextBox)
Dim calendarObject As Calendar = CType(sender, Calendar)
dateTextBox.Text = calendarObject.SelectedDate.ToString("d")
End Sub
Function GetDateTime(ByVal dateValue As Object) As DateTime
If dateValue Is DBNull.Value Then
Return DateTime.Now
Else
Return CType(dateValue, DateTime)
End If
End Function
Protected Sub ProductsListView_PagePropertiesChanging(ByVal sender As Object, _
ByVal e As PagePropertiesChangingEventArgs)
' Clears the edit index selection when paging.
ProductsListView.EditIndex = -1
End Sub
</script>
<html >
<head id="Head1" runat="server">
<title>ListView Edit Item Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>ListView Edit Item Example</h3>
<asp:Label ID="Message"
ForeColor="Red"
runat="server"/>
<br/>
<asp:ListView ID="ProductsListView"
DataSourceID="ProductsDataSource"
DataKeyNames="ProductID"
OnItemEditing="ProductsListView_ItemEditing"
ConvertEmptyStringToNull="true"
OnPagePropertiesChanging="ProductsListView_PagePropertiesChanging"
runat="server" >
<LayoutTemplate>
<table cellpadding="2" runat="server" id="tblProducts" width="640px">
<tr runat="server" id="itemPlaceholder" />
</table>
<asp:DataPager runat="server" ID="ProductsDataPager" 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" />
</td>
<td valign="top">
<asp:Label ID="NameLabel" runat="server" Text='<%#Eval("Name") %>' />
</td>
<td valign="top">
<asp:Label ID="ProductNumberLabel" runat="server" Text='<%#Eval("ProductNumber") %>' />
</td>
<td>
<asp:Label ID="DiscontinuedDateLabel" runat="server"
Text='<%#Eval("DiscontinuedDate", "{0:d}") %>' />
</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="CancelButton" runat="server"
CommandName="Cancel" Text="Cancel" />
</td>
<td valign="top" colspan="2">
<asp:Label runat="server" ID="NameLabel"
AssociatedControlID="NameTextBox"
Text="Name"/>
<asp:TextBox ID="NameTextBox" runat="server"
Text='<%#Bind("Name") %>' MaxLength="50" /><br />
<asp:Label runat="server" ID="ProductNumberLabel"
AssociatedControlID="ProductNumberTextBox"
Text="Product Number" />
<asp:TextBox ID="ProductNumberTextBox" runat="server"
Text='<%#Bind("ProductNumber") %>' MaxLength="25" /><br />
</td>
<td>
<asp:Label runat="server" ID="DiscontinuedDateLabel"
AssociatedControlID="DiscontinuedDateTextBox"
Text="Discontinued Date"/>
<asp:TextBox ID="DiscontinuedDateTextBox" runat="server"
Text='<%# Bind("DiscontinuedDate", "{0:d}") %>'
MaxLength="10" /><br />
<asp:Calendar ID="DiscontinuedDateCalendar" runat="server"
SelectedDate='<%# GetDateTime(Eval("DiscontinuedDate")) %>'
OnSelectionChanged="DiscontinuedDateCalendar_OnSelectionChanged" />
</td>
</tr>
</EditItemTemplate>
</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="ProductsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
SelectCommand="SELECT [ProductID], [Name], [ProductNumber], [DiscontinuedDate]
FROM Production.Product"
UpdateCommand="UPDATE Production.Product
SET Name = @Name, ProductNumber = @ProductNumber, DiscontinuedDate = @DiscontinuedDate
WHERE ProductID = @ProductID">
</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;
}
void ProductsListView_ItemEditing(Object sender, ListViewEditEventArgs e)
{
ListViewItem item = ProductsListView.Items[e.NewEditIndex];
Label dateLabel = (Label)item.FindControl("DiscontinuedDateLabel");
if (String.IsNullOrEmpty(dateLabel.Text))
return;
//Verify if the item is discontinued.
DateTime discontinuedDate = DateTime.Parse(dateLabel.Text);
if (discontinuedDate < DateTime.Now)
{
Message.Text = "You cannot edit a discontinued item.";
e.Cancel = true;
ProductsListView.SelectedIndex = -1;
}
}
void DiscontinuedDateCalendar_OnSelectionChanged(Object sender, EventArgs e)
{
TextBox dateTextBox =
(TextBox)ProductsListView.EditItem.FindControl("DiscontinuedDateTextBox");
Calendar calendarObject = (Calendar)sender;
dateTextBox.Text = calendarObject.SelectedDate.ToString("d");
}
DateTime GetDateTime(object dateValue)
{
if (dateValue == DBNull.Value)
return DateTime.Now;
else
return (DateTime)dateValue;
}
protected void ProductsListView_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
{
// Clears the edit index selection when paging.
ProductsListView.EditIndex = -1;
}
</script>
<html >
<head id="Head1" runat="server">
<title>ListView Edit Item Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>ListView Edit Item Example</h3>
<asp:Label ID="Message"
ForeColor="Red"
runat="server"/>
<br/>
<asp:ListView ID="ProductsListView"
DataSourceID="ProductsDataSource"
DataKeyNames="ProductID"
OnItemEditing="ProductsListView_ItemEditing"
ConvertEmptyStringToNull="true"
OnPagePropertiesChanging="ProductsListView_PagePropertiesChanging"
runat="server" >
<LayoutTemplate>
<table cellpadding="2" runat="server" id="tblProducts" width="640px">
<tr runat="server" id="itemPlaceholder" />
</table>
<asp:DataPager runat="server" ID="ProductsDataPager" 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" />
</td>
<td valign="top">
<asp:Label ID="NameLabel" runat="server" Text='<%#Eval("Name") %>' />
</td>
<td valign="top">
<asp:Label ID="ProductNumberLabel" runat="server" Text='<%#Eval("ProductNumber") %>' />
</td>
<td>
<asp:Label ID="DiscontinuedDateLabel" runat="server"
Text='<%#Eval("DiscontinuedDate", "{0:d}") %>' />
</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="CancelButton" runat="server"
CommandName="Cancel" Text="Cancel" />
</td>
<td valign="top" colspan="2">
<asp:Label runat="server" ID="NameLabel"
AssociatedControlID="NameTextBox"
Text="Name"/>
<asp:TextBox ID="NameTextBox" runat="server"
Text='<%#Bind("Name") %>' MaxLength="50" /><br />
<asp:Label runat="server" ID="ProductNumberLabel"
AssociatedControlID="ProductNumberTextBox"
Text="Product Number" />
<asp:TextBox ID="ProductNumberTextBox" runat="server"
Text='<%#Bind("ProductNumber") %>' MaxLength="25" /><br />
</td>
<td>
<asp:Label runat="server" ID="DiscontinuedDateLabel"
AssociatedControlID="DiscontinuedDateTextBox"
Text="Discontinued Date"/>
<asp:TextBox ID="DiscontinuedDateTextBox" runat="server"
Text='<%# Bind("DiscontinuedDate", "{0:d}") %>'
MaxLength="10" /><br />
<asp:Calendar ID="DiscontinuedDateCalendar" runat="server"
SelectedDate='<%# GetDateTime(Eval("DiscontinuedDate")) %>'
OnSelectionChanged="DiscontinuedDateCalendar_OnSelectionChanged" />
</td>
</tr>
</EditItemTemplate>
</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="ProductsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
SelectCommand="SELECT [ProductID], [Name], [ProductNumber], [DiscontinuedDate]
FROM Production.Product"
UpdateCommand="UPDATE Production.Product
SET Name = @Name, ProductNumber = @ProductNumber, DiscontinuedDate = @DiscontinuedDate
WHERE ProductID = @ProductID">
</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 ListViewEditEventArgs, 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 ListViewEditEventArgs _
Inherits CancelEventArgs
public class ListViewEditEventArgs : CancelEventArgs
public ref class ListViewEditEventArgs : public CancelEventArgs
type ListViewEditEventArgs =
class
inherit CancelEventArgs
end
Le type ListViewEditEventArgs expose les membres suivants.

Constructeurs

Propriétés

Méthodes

Notes
Le contrôle ListView déclenche l'événement ItemEditing lorsqu'un utilisateur clique sur le bouton Modifier, avant que l'élément ListView ne soit passé en mode édition. (Un bouton Modifier est un bouton dont la propriété CommandName a la valeur « Edit ».) Cela vous permet de fournir une méthode de gestion d'événements qui exécute une routine personnalisée, par exemple l'annulation de l'opération de modification, chaque fois que cet événement se produit. Un objet ListViewEditEventArgs est passé à la méthode de gestion d'événements. Cet objet vous permet de déterminer l'index de l'élément modifié et d'indiquer que la modification doit être annulée. Pour annuler l'opération de modification, affectez la valeur true à la propriété Cancel de l'objet ListViewEditEventArgs. Pour obtenir la liste des valeurs de propriétés initiales d'une instance de ListViewEditEventArgs, consultez le constructeur ListViewEditEventArgs.

Exemples
L'exemple suivant indique comment utiliser l'objet ListViewEditEventArgs pour annuler la modification lorsque l'utilisateur essaie de mettre à jour un élément arrêté. Note de sécurité |
|---|
Cet exemple a 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
Sub ProductsListView_ItemEditing(ByVal sender As Object, ByVal e As ListViewEditEventArgs)
Dim item As ListViewItem = ProductsListView.Items(e.NewEditIndex)
Dim dateLabel As Label = CType(item.FindControl("DiscontinuedDateLabel"), Label)
If String.IsNullOrEmpty(dateLabel.Text) Then _
Return
'Verify if the item is discontinued.
Dim discontinuedDate As DateTime = DateTime.Parse(dateLabel.Text)
If discontinuedDate < DateTime.Now Then
Message.Text = "You cannot edit a discontinued item."
e.Cancel = True
ProductsListView.SelectedIndex = -1
End If
End Sub
Sub DiscontinuedDateCalendar_OnSelectionChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim dateTextBox As TextBox = _
CType(ProductsListView.EditItem.FindControl("DiscontinuedDateTextBox"), TextBox)
Dim calendarObject As Calendar = CType(sender, Calendar)
dateTextBox.Text = calendarObject.SelectedDate.ToString("d")
End Sub
Function GetDateTime(ByVal dateValue As Object) As DateTime
If dateValue Is DBNull.Value Then
Return DateTime.Now
Else
Return CType(dateValue, DateTime)
End If
End Function
Protected Sub ProductsListView_PagePropertiesChanging(ByVal sender As Object, _
ByVal e As PagePropertiesChangingEventArgs)
' Clears the edit index selection when paging.
ProductsListView.EditIndex = -1
End Sub
</script>
<html >
<head id="Head1" runat="server">
<title>ListView Edit Item Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>ListView Edit Item Example</h3>
<asp:Label ID="Message"
ForeColor="Red"
runat="server"/>
<br/>
<asp:ListView ID="ProductsListView"
DataSourceID="ProductsDataSource"
DataKeyNames="ProductID"
OnItemEditing="ProductsListView_ItemEditing"
ConvertEmptyStringToNull="true"
OnPagePropertiesChanging="ProductsListView_PagePropertiesChanging"
runat="server" >
<LayoutTemplate>
<table cellpadding="2" runat="server" id="tblProducts" width="640px">
<tr runat="server" id="itemPlaceholder" />
</table>
<asp:DataPager runat="server" ID="ProductsDataPager" 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" />
</td>
<td valign="top">
<asp:Label ID="NameLabel" runat="server" Text='<%#Eval("Name") %>' />
</td>
<td valign="top">
<asp:Label ID="ProductNumberLabel" runat="server" Text='<%#Eval("ProductNumber") %>' />
</td>
<td>
<asp:Label ID="DiscontinuedDateLabel" runat="server"
Text='<%#Eval("DiscontinuedDate", "{0:d}") %>' />
</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="CancelButton" runat="server"
CommandName="Cancel" Text="Cancel" />
</td>
<td valign="top" colspan="2">
<asp:Label runat="server" ID="NameLabel"
AssociatedControlID="NameTextBox"
Text="Name"/>
<asp:TextBox ID="NameTextBox" runat="server"
Text='<%#Bind("Name") %>' MaxLength="50" /><br />
<asp:Label runat="server" ID="ProductNumberLabel"
AssociatedControlID="ProductNumberTextBox"
Text="Product Number" />
<asp:TextBox ID="ProductNumberTextBox" runat="server"
Text='<%#Bind("ProductNumber") %>' MaxLength="25" /><br />
</td>
<td>
<asp:Label runat="server" ID="DiscontinuedDateLabel"
AssociatedControlID="DiscontinuedDateTextBox"
Text="Discontinued Date"/>
<asp:TextBox ID="DiscontinuedDateTextBox" runat="server"
Text='<%# Bind("DiscontinuedDate", "{0:d}") %>'
MaxLength="10" /><br />
<asp:Calendar ID="DiscontinuedDateCalendar" runat="server"
SelectedDate='<%# GetDateTime(Eval("DiscontinuedDate")) %>'
OnSelectionChanged="DiscontinuedDateCalendar_OnSelectionChanged" />
</td>
</tr>
</EditItemTemplate>
</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="ProductsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
SelectCommand="SELECT [ProductID], [Name], [ProductNumber], [DiscontinuedDate]
FROM Production.Product"
UpdateCommand="UPDATE Production.Product
SET Name = @Name, ProductNumber = @ProductNumber, DiscontinuedDate = @DiscontinuedDate
WHERE ProductID = @ProductID">
</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;
}
void ProductsListView_ItemEditing(Object sender, ListViewEditEventArgs e)
{
ListViewItem item = ProductsListView.Items[e.NewEditIndex];
Label dateLabel = (Label)item.FindControl("DiscontinuedDateLabel");
if (String.IsNullOrEmpty(dateLabel.Text))
return;
//Verify if the item is discontinued.
DateTime discontinuedDate = DateTime.Parse(dateLabel.Text);
if (discontinuedDate < DateTime.Now)
{
Message.Text = "You cannot edit a discontinued item.";
e.Cancel = true;
ProductsListView.SelectedIndex = -1;
}
}
void DiscontinuedDateCalendar_OnSelectionChanged(Object sender, EventArgs e)
{
TextBox dateTextBox =
(TextBox)ProductsListView.EditItem.FindControl("DiscontinuedDateTextBox");
Calendar calendarObject = (Calendar)sender;
dateTextBox.Text = calendarObject.SelectedDate.ToString("d");
}
DateTime GetDateTime(object dateValue)
{
if (dateValue == DBNull.Value)
return DateTime.Now;
else
return (DateTime)dateValue;
}
protected void ProductsListView_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
{
// Clears the edit index selection when paging.
ProductsListView.EditIndex = -1;
}
</script>
<html >
<head id="Head1" runat="server">
<title>ListView Edit Item Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>ListView Edit Item Example</h3>
<asp:Label ID="Message"
ForeColor="Red"
runat="server"/>
<br/>
<asp:ListView ID="ProductsListView"
DataSourceID="ProductsDataSource"
DataKeyNames="ProductID"
OnItemEditing="ProductsListView_ItemEditing"
ConvertEmptyStringToNull="true"
OnPagePropertiesChanging="ProductsListView_PagePropertiesChanging"
runat="server" >
<LayoutTemplate>
<table cellpadding="2" runat="server" id="tblProducts" width="640px">
<tr runat="server" id="itemPlaceholder" />
</table>
<asp:DataPager runat="server" ID="ProductsDataPager" 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" />
</td>
<td valign="top">
<asp:Label ID="NameLabel" runat="server" Text='<%#Eval("Name") %>' />
</td>
<td valign="top">
<asp:Label ID="ProductNumberLabel" runat="server" Text='<%#Eval("ProductNumber") %>' />
</td>
<td>
<asp:Label ID="DiscontinuedDateLabel" runat="server"
Text='<%#Eval("DiscontinuedDate", "{0:d}") %>' />
</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="CancelButton" runat="server"
CommandName="Cancel" Text="Cancel" />
</td>
<td valign="top" colspan="2">
<asp:Label runat="server" ID="NameLabel"
AssociatedControlID="NameTextBox"
Text="Name"/>
<asp:TextBox ID="NameTextBox" runat="server"
Text='<%#Bind("Name") %>' MaxLength="50" /><br />
<asp:Label runat="server" ID="ProductNumberLabel"
AssociatedControlID="ProductNumberTextBox"
Text="Product Number" />
<asp:TextBox ID="ProductNumberTextBox" runat="server"
Text='<%#Bind("ProductNumber") %>' MaxLength="25" /><br />
</td>
<td>
<asp:Label runat="server" ID="DiscontinuedDateLabel"
AssociatedControlID="DiscontinuedDateTextBox"
Text="Discontinued Date"/>
<asp:TextBox ID="DiscontinuedDateTextBox" runat="server"
Text='<%# Bind("DiscontinuedDate", "{0:d}") %>'
MaxLength="10" /><br />
<asp:Calendar ID="DiscontinuedDateCalendar" runat="server"
SelectedDate='<%# GetDateTime(Eval("DiscontinuedDate")) %>'
OnSelectionChanged="DiscontinuedDateCalendar_OnSelectionChanged" />
</td>
</tr>
</EditItemTemplate>
</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="ProductsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
SelectCommand="SELECT [ProductID], [Name], [ProductNumber], [DiscontinuedDate]
FROM Production.Product"
UpdateCommand="UPDATE Production.Product
SET Name = @Name, ProductNumber = @ProductNumber, DiscontinuedDate = @DiscontinuedDate
WHERE ProductID = @ProductID">
</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
|