DetailsView

 

 实现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>

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值