ASP.NET Web Form GridView DetailsView Query Edit

來源:互聯網
上載者:User
<%@ Page language="C#" validaterequest="false" enableviewstate="false"%><!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>        <title>            DetailsView GridView Query Edit Example        </title>        <meta name="generator" content="editplus" />        <meta name="author" content="" />        <meta name="keywords" content="" />        <meta name="description" content="" />    </head><body>    <form id="form1" runat="server">            <asp:DetailsView                ID="DetailsView1"                runat="server"                AutoGenerateRows="false"                DefaultMode="Insert"                DataKeyNames="RowID"                DataSourceID="SqlDataSource1"            >                <Fields>                    <asp:BoundField                        DataField="Field01"                        HeaderText="Field01"                    />                    <asp:BoundField                        DataField="Field02"                        HeaderText="Field02"                    />                    <asp:BoundField                        DataField="Field03"                        HeaderText="Field03"                    />                    <asp:TemplateField                        ShowHeader="False"                    >                        <InsertItemTemplate>                            <asp:Button                                ID="Button1"                                runat="server"                                CausesValidation="True"                                 CommandName="Insert"                                Text="插入"                                OnClientClick="return confirm('add?')"                            />                            <input type="reset" />                        </InsertItemTemplate>                    </asp:TemplateField>                </Fields>            </asp:DetailsView>        <BR>        Field01:         <asp:TextBox            ID="TextBox1"            runat="server"        />        <asp:Button            ID="Button1"            runat="server"            Text="查詢"        />        <BR>        <asp:gridview            id="GridView1"             datasourceid="SqlDataSource1"             autogeneratecolumns="true"            allowpaging="true"            pagesize="20"            datakeynames="RowID"            runat="server"        >            <Columns>                <asp:TemplateField                    ShowHeader="False"                >                    <ItemTemplate>                        <asp:LinkButton                            ID="LinkButton1"                            runat="server"                            CausesValidation="False"                             CommandName="Delete"                            Text="刪除"                            OnClientClick="return confirm('delete?')"                        />                    </ItemTemplate>                </asp:TemplateField>                <asp:TemplateField                    ShowHeader="False"                >                    <EditItemTemplate>                        <asp:LinkButton                            ID="LinkButton2"                            runat="server"                            CausesValidation="True"                             CommandName="Update"                            Text="更新"                            OnClientClick="return confirm('update?')"                        />                        &nbsp;                        <asp:LinkButton                            ID="LinkButton3"                            runat="server"                            CausesValidation="False"                             CommandName="Cancel"                            Text="取消"                        />                    </EditItemTemplate>                    <ItemTemplate>                        <asp:LinkButton                            ID="LinkButton4"                            runat="server"                            CausesValidation="False"                             CommandName="Edit"                            Text="編輯"                        />                    </ItemTemplate>                </asp:TemplateField>            </Columns>        </asp:gridview>        <!-- to do -->        <asp:sqldatasource            id="SqlDataSource1"            selectcommand="execute xsp_TableName_SelectAll @Field01"            updatecommand="execute xsp_TableName_UpdateByRowID @RowID,@Field01,@Field02,@Field03"            insertcommand="execute xsp_TableName_Insert @Field01,@Field02,@Field03"            deletecommand="execute xsp_TableName_DeleteByRowID @RowID"            connectionstring="Application Name=AppTest;Integrated Security=SSPI;Persist Security Info=False;Data Source=SQLServerName;database=DataBaseName"            runat="server"        >            <SelectParameters>                <asp:ControlParameter                    ControlID="TextBox1"                    Name="Field01"                    PropertyName="Text"                    DefaultValue=" "                    DbType="String"                />            </SelectParameters>        </asp:sqldatasource>    </form></body></html>
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.