zoukankan      html  css  js  c++  java
  • ASP.NET Web Form GridView DetailsView Query Edit

    
    <%@ 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>
    
    
  • 相关阅读:
    eclipse中的Invalid text string (xxx).
    在jsp文件中出现Unknown tag (c:out)
    eclipse 界面复原
    ecilpse 纠错插件
    Multiple annotations found at this line:- The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
    Port 8080 required by Tomcat v9.0 Server at localhost is already in use. The server may already be running in another process, or a system process may be using the port.
    调用第三方https接口
    调用第三方http接口
    创建带值枚举
    spring整合redis之Redis配置文件
  • 原文地址:https://www.cnblogs.com/Microshaoft/p/1744488.html
Copyright © 2011-2022 走看看