Visual Studio Web Developer(C#) - GridView和FormView

时间:2012-02-17 18:48:45

标签: c# asp.net visual-studio visual-web-developer

我在Visual Web Developer(ASP.NET - C#)中有这个功课,不幸的是我没有足够的时间来完成正确的研究 - 我必须创建GridView以便在数据库中显示数据。我遇到的问题是:

当我单击连续编辑按钮时,我应该转到“FormView的编辑模式”或看起来像“GridView的编辑模式”的东西(所以点击编辑后我应该看到对于相应表记录的每一列gridview,只有一行有1行,而不是只有一行改为TextBox的记录的Gridview ......)。

请考虑使用Default.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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 runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            DataKeyNames="id_people" DataSourceID="SqlDataSource1" 
            EmptyDataText="There are no data records to display.">
            <Columns>
                <asp:CommandField ShowEditButton="True" />
                <asp:BoundField DataField="id_people" HeaderText="id_people" ReadOnly="True" 
                    SortExpression="id_people" />
                <asp:BoundField DataField="first_name" HeaderText="first_name" 
                    SortExpression="first_name" />
                <asp:BoundField DataField="last_name" HeaderText="last_name" 
                    SortExpression="last_name" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:InsertRowsWithGridViewConnectionString1 %>" 
            SelectCommand="SELECT [id_people], [first_name], [last_name] FROM [Table1]" 
            UpdateCommand="UPDATE [Table1] SET [first_name] = @first_name, [last_name] = @last_name WHERE [id_people] = @id_people">
            <UpdateParameters>
                <asp:Parameter Name="first_name" Type="String" />
                <asp:Parameter Name="last_name" Type="String" />
                <asp:Parameter Name="id_people" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>

    </div>
    </form>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

 <asp:Panel ID="pnlAddPropertyDetails" runat="server" CssClass="ui-dialog ui-widget ui-widget-content ui-corner-all"
        Width="400" EnableViewState="True">
        <div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix">
            <span class="ui-dialog-title">
                Add Property Details</span>
            <a class="ui-dialog-titlebar-close ui-corner-all"></a>
        </div>
        <div class="ui-dialog-content ui-widget-content">
            //ur content of dialog here
        </div>
    </asp:Panel>

不要忘记添加jquery的css文件来利用他们的类