实现DetailsView分页:
<div>
实现DetailsView分页<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True"
AutoGenerateRows="False" DataSourceID="SqlDataSource1" Height="50px" Width="163px">
<Fields>
<asp:BoundField DataField="StuID" HeaderText="StuID" SortExpression="StuID" />
<asp:BoundField DataField="Stuname" HeaderText="Stuname" SortExpression="Stuname" />
<asp:BoundField DataField="Stuage" HeaderText="Stuage" SortExpression="Stuage" />
<asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
<asp:BoundField DataField="Zip" HeaderText="Zip" SortExpression="Zip" />
<asp:BoundField DataField="Grade" HeaderText="Grade" SortExpression="Grade" />
<asp:BoundField DataField="Class" HeaderText="Class" SortExpression="Class" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DatabindControlsConnectionString %>"
SelectCommand="SELECT * FROM [student]"></asp:SqlDataSource>
</div>
实现DetailsVies编辑功能:
<div>
实现DetailsVies编辑功能<br />
<br />
<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False"
DataSourceID="SqlDataSource1" Height="50px" Width="125px">
<Fields>
<asp:BoundField DataField="StuID" HeaderText="StuID" SortExpression="StuID" />
<asp:BoundField DataField="Stuname" HeaderText="Stuname" SortExpression="Stuname" />
<asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
<asp:BoundField DataField="Grade" HeaderText="Grade" SortExpression="Grade" />
<asp:CommandField ShowEditButton="True" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DatabindControlsConnectionString %>"
SelectCommand="SELECT [StuID], [Stuname], [Address], [Grade] FROM [student]" UpdateCommand="update student set StuID=@StuID,Stuname=@Stuname,Address=@Address,Grade=@Grade where StuID=@StuID"></asp:SqlDataSource>
</div>
GridView控件+数据行详细信息:
<div>
1。联合GridView控件<br />
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="2"
DataKeyNames="StuID" DataSourceID="SqlDataSource1" ForeColor="Black" GridLines="None"
PageSize="5">
<FooterStyle BackColor="Tan" />
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="StuID" HeaderText="StuID" SortExpression="StuID" />
<asp:BoundField DataField="Stuname" HeaderText="Stuname" SortExpression="Stuname" />
<asp:BoundField DataField="Stuage" HeaderText="Stuage" SortExpression="Stuage" />
<asp:BoundField DataField="Grade" HeaderText="Grade" SortExpression="Grade" />
</Columns>
<SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
<HeaderStyle BackColor="Tan" Font-Bold="True" />
<AlternatingRowStyle BackColor="PaleGoldenrod" />
</asp:GridView>
<br />
数据行详细信息:<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DatabindControlsConnectionString %>"
SelectCommand="SELECT [StuID], [Stuname], [Stuage], [Grade] FROM [student]"></asp:SqlDataSource>
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" BackColor="White"
BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataSourceID="SqlDataSource2"
GridLines="Vertical" Height="50px" Width="325px">
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<EditRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<Fields>
<asp:BoundField DataField="StuID" HeaderText="StuID" SortExpression="StuID">
<ControlStyle Width="80px" />
</asp:BoundField>
<asp:BoundField DataField="Stuname" HeaderText="Stuname" SortExpression="Stuname" />
<asp:BoundField DataField="Stuage" HeaderText="Stuage" SortExpression="Stuage" />
<asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
<asp:BoundField DataField="Zip" HeaderText="Zip" SortExpression="Zip" />
<asp:BoundField DataField="Grade" HeaderText="Grade" SortExpression="Grade" />
<asp:BoundField DataField="Class" HeaderText="Class" SortExpression="Class" />
</Fields>
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="#DCDCDC" />
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:DatabindControlsConnectionString %>"
SelectCommand="SELECT * FROM [student] WHERE ([StuID] = @StuID)">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="StuID" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</div>