<html>
<title>DetailsView AutoGenerateEditButton Example</title>
<link rel="stylesheet" href="/shared/netdemos.css">
</head>
<body>
<!-- #include virtual="~/shared/top.inc" -->
<div class="header"><h2>DetailsView <span class="hilite">AutoGenerateEditButton</span> Example</h2></div>
<hr size=1 width=92%>
<form runat="server">
<div align="center">
<asp:detailsview id="guestDetails" runat="server"
width=75% cellpadding=5
datasourceid="guests"
datakeynames="GuestID"
autogenerateeditbutton
allowpaging
autogeneraterows=false>
<rowstyle
backcolor="ghostwhite"
verticalalign="top" />
<commandrowstyle font-bold
horizontalalign="center" />
<fieldheaderstyle width=30%
backcolor="lightsteelblue"
horizontalalign="right" />
<fields>
<asp:boundfield datafield="guestid"
headertext="Guest ID"
readonly="true" />
<asp:boundfield datafield="nickname"
headertext="Nickname" />
<asp:templatefield headertext="Gender">
<itemtemplate>
<asp:label id="genderlabel" runat="server"
text='<%# Eval ( "gender" ) %>' />
</itemtemplate>
<edititemtemplate>
<asp:radiobuttonlist id="editgender" runat="server"
repeatdirection="horizontal"
selectedvalue='<%# Bind ( "gender" ) %>'>
<asp:listitem value="M" text="Male" />
<asp:listitem value="F" text="Female" />
<asp:listitem value="" text="Neutral" />
</asp:radiobuttonlist>
</edititemtemplate>
</asp:templatefield>
<asp:templatefield headertext="State">
<itemtemplate>
<asp:label id="statelabel" runat="server"
text='<%# Eval ( "state" ) %>' />
</itemtemplate>
<edititemtemplate>
<asp:dropdownlist id="editstate" runat="server"
datasourceid="states"
datatextfield="state"
datavaluefield="stateid"
selectedvalue='<%# Bind ( "state" ) %>' />
</edititemtemplate>
</asp:templatefield>
<asp:templatefield headertext="Lucky Date">
<itemtemplate>
<asp:label id="luckydatelabel" runat="server"
text='<%# Eval ( "luckydate", "{0:d}" ) %>' />
</itemtemplate>
<edititemtemplate>
<asp:calendar id="editluckydatecalendar" runat="server"
backcolor="khaki"
titlestyle-backcolor="yellowgreen"
selecteddaystyle-backcolor="sienna"
visibledate='<%# Eval ( "luckydate" ) %>'
selecteddate='<%# Bind ( "luckydate" ) %>' />
</edititemtemplate>
</asp:templatefield>
<asp:checkboxfield datafield="married"
headertext="Married?" />
</fields>
</asp:detailsview>
<asp:sqldatasource id="guests" runat="server"
selectcommand="SELECT * FROM aspx_guests"
updatecommand="UPDATE aspx_guests SET
Nickname=@Nickname, Gender=@Gender,
LuckyDate=@LuckyDate, State=@State, Married=@Married
WHERE GuestId=@GuestId"
connectionstring="<%$ ConnectionStrings:aspnet %>" />
<asp:accessdatasource id="states" runat="server"
datafile="~/app_data/usa.mdb"
datasourcemode="datareader"
selectcommand="SELECT State, StateId FROM States" />
</div>
</form>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>