<%@ Page language="C#" validaterequest="false" enableviewstate="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>
DetailsView GridView Query Edit Example
</title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
</head>
<body>
<form id="form1" runat="server">
<asp:DetailsView
ID="DetailsView1"
runat="server"
AutoGenerateRows="false"
DefaultMode="Insert"
DataKeyNames="RowID"
DataSourceID="SqlDataSource1"
>
<Fields>
<asp:BoundField
DataField="Field01"
HeaderText="Field01"
/>
<asp:BoundField
DataField="Field02"
HeaderText="Field02"
/>
<asp:BoundField
DataField="Field03"
HeaderText="Field03"
/>
<asp:TemplateField
ShowHeader="False"
>
<InsertItemTemplate>
<asp:Button
ID="Button1"
runat="server"
CausesValidation="True"
CommandName="Insert"
Text="插入"
OnClientClick="return confirm('add?')"
/>
<input type="reset" />
</InsertItemTemplate>
</asp:TemplateField>
</Fields>
</asp:DetailsView>
<BR>
Field01:
<asp:TextBox
ID="TextBox1"
runat="server"
/>
<asp:Button
ID="Button1"
runat="server"
Text="查询"
/>
<BR>
<asp:gridview
id="GridView1"
datasourceid="SqlDataSource1"
autogeneratecolumns="true"
allowpaging="true"
pagesize="20"
datakeynames="RowID"
runat="server"
>
<Columns>
<asp:TemplateField
ShowHeader="False"
>
<ItemTemplate>
<asp:LinkButton
ID="LinkButton1"
runat="server"
CausesValidation="False"
CommandName="Delete"
Text="删除"
OnClientClick="return confirm('delete?')"
/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField
ShowHeader="False"
>
<EditItemTemplate>
<asp:LinkButton
ID="LinkButton2"
runat="server"
CausesValidation="True"
CommandName="Update"
Text="更新"
OnClientClick="return confirm('update?')"
/>
<asp:LinkButton
ID="LinkButton3"
runat="server"
CausesValidation="False"
CommandName="Cancel"
Text="取消"
/>
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton
ID="LinkButton4"
runat="server"
CausesValidation="False"
CommandName="Edit"
Text="编辑"
/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:gridview>
<!-- to do -->
<asp:sqldatasource
id="SqlDataSource1"
selectcommand="execute xsp_TableName_SelectAll @Field01"
updatecommand="execute xsp_TableName_UpdateByRowID @RowID,@Field01,@Field02,@Field03"
insertcommand="execute xsp_TableName_Insert @Field01,@Field02,@Field03"
deletecommand="execute xsp_TableName_DeleteByRowID @RowID"
connectionstring="Application Name=AppTest;Integrated Security=SSPI;Persist Security Info=False;Data Source=SQLServerName;database=DataBaseName"
runat="server"
>
<SelectParameters>
<asp:ControlParameter
ControlID="TextBox1"
Name="Field01"
PropertyName="Text"
DefaultValue=" "
DbType="String"
/>
</SelectParameters>
</asp:sqldatasource>
</form>
</body>
</html>