Illustrates how to execute an inline SQL command.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<style type="text/css">
.detailsView
{
margin:0px auto;
border:solid 4px black;
background-color:white;
}
.detailsView td
{
padding:8px;
}
html
{
background-color:silver;
font-family:Georgia, Serif;
}
a
{
color:blue;
text-decoration:none;
}
</style>
<title>Show Inline Commands</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DetailsView
id="dtlMovies"
DataSourceID="srcMovies"
DataKeyNames="Id"
AllowPaging="true"
AutoGenerateEditButton="true"
AutoGenerateInsertButton="true"
AutoGenerateDeleteButton="true"
AutoGenerateRows="false"
CssClass="detailsView"
PagerSettings-Mode="NumericFirstLast"
Runat="server">
<Fields>
<asp:BoundField DataField="Id"
HeaderText="Movie Id:" ReadOnly="true" InsertVisible="false" />
<asp:BoundField DataField="Title" HeaderText="Movie Title:" />
<asp:BoundField DataField="Director" HeaderText="Movie Director:" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource
id="srcMovies"
SelectCommand="SELECT Id,Title,Director FROM Movies"
InsertCommand="INSERT Movies (Title,Director,CategoryId,DateReleased)
VALUES (@Title, @Director,0,'12/15/1966')"
UpdateCommand="UPDATE Movies SET Title=@Title,
Director=@Director WHERE Id=@Id"
DeleteCommand="DELETE Movies WHERE Id=@Id"
ConnectionString="<%$ ConnectionStrings:Movies %>"
Runat="server" />
</div>
</form>
</body>
</html>