用ListView控件編輯數據
正如你所看到的
清單
<%@ Page Language=
<script runat=
void deptsView_ItemUpdated(object sender
ListViewUpdatedEventArgs e)
{
lblResult
}
void deptsView_PagePropertiesChanged(object sender
{
//Set the text to empty when navigating to a different page
lblResult
}
</script>
<html xmlns=
<head runat=
<link rel=
<title>Editing Data using ListView Control</title>
</head>
<body>
<form id=
<div>
<asp:ListView ID=
DataKeyNames=
OnItemUpdated=
OnPagePropertiesChanged=
<LayoutTemplate>
<table cellpadding=
runat=
<tr id=
<th id=
<th id=
<th id=
</tr>
<tr runat=
</table>
<asp:DataPager runat=
PageSize=
<Fields>
<asp:NextPreviousPagerField ShowFirstPageButton=
ShowLastPageButton=
LastPageText=
PreviousPageText=
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<tr id=
<td>
<asp:Label ID=
Text=
</td>
<td valign=
<asp:Label ID=
Text=
</td>
<td>
<asp:LinkButton ID=
CommandName=
</td>
</tr>
</ItemTemplate>
<EditItemTemplate>
<tr style=
<td>
<asp:TextBox ID=
Text=
MaxLength=
</td>
<td>
<asp:TextBox ID=
Bind(
</td>
<td>
<asp:LinkButton ID=
CommandName=
<asp:LinkButton ID=
CommandName=
</td>
</tr>
</EditItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID=
ConnectionString=
SelectCommand=
HumanResources
HumanResources
GroupName = @GroupName WHERE DepartmentID = @DepartmentID
</asp:SqlDataSource>
<br /><br />
<asp:Label runat=
Font
</div>
</form>
</body>
</html>
清單
首先
<asp:SqlDataSource ID=
ConnectionString=
SelectCommand=
HumanResources
HumanResources
GroupName = @GroupName WHERE DepartmentID = @DepartmentID
</asp:SqlDataSource>
接下來
<ItemTemplate>
<asp:LinkButton ID=
CommandName=
</td>
</tr>
</ItemTemplate>
然後
<EditItemTemplate>
<tr style=
<td>
<asp:TextBox ID=
Text=
MaxLength=
</td>
<td>
<asp:TextBox ID=
Bind(
</td>
<td>
<asp:LinkButton ID=
CommandName=
<asp:LinkButton ID=
CommandName=
</td>
</tr>
</EditItemTemplate>
[
From:http://tw.wingwit.com/Article/program/net/201311/14844.html