zoukankan      html  css  js  c++  java
  • SqlDataSource 调用带参数的存储过程

     

    <%@ Page Language="VB" %>

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

     

    <script runat="server">

     

        Protected Sub btnShow_Click(ByVal sender As Object, ByVal e As System.EventArgs)

            Me.gvParam.DataBind()

        End Sub

    </script>

     

    <html xmlns="http://www.w3.org/1999/xhtml" >

    <head runat="server">

        <title>sqlDataSource执行带参数的存储过程</title>

    </head>

    <body>

        <form id="form1" runat="server">

        <div>

            <%-- gvParam --%>

            <asp:GridView ID="gvParam" Caption ="Param" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="sqlDsParam">

                <Columns>

                    <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" />

                    <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />

                    <asp:BoundField DataField="Author" HeaderText="Author" SortExpression="Author" />

                    <asp:BoundField DataField="Descrip" HeaderText="Descrip" SortExpression="Descrip" />

                    <asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />

                    <asp:BoundField DataField="Size" HeaderText="Size" SortExpression="Size" />

                    <asp:CommandField ShowDeleteButton="True" />

                </Columns>

            </asp:GridView>

           

            <asp:TextBox ID="txtID" runat="server" Width="67px" Text ="1" />

            <asp:Button ID="btnShow" runat="server" OnClick="btnShow_Click" Text="Show" />

           

            <%-- gvAll --%>

            <asp:GridView ID="gvAll" Caption ="gvAll" runat="server" AutoGenerateColumns="False" DataSourceID="sqlDsAll">

                <Columns>

                    <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" />

                    <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />

                    <asp:BoundField DataField="Author" HeaderText="Author" SortExpression="Author" />

                    <asp:BoundField DataField="Descrip" HeaderText="Descrip" SortExpression="Descrip" />

                    <asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />

                    <asp:BoundField DataField="Size" HeaderText="Size" SortExpression="Size" />

                </Columns>

            </asp:GridView>

            <%-- DataSource: sqlDsAll --%>

            <asp:SqlDataSource ID="sqlDsAll" runat="server" ConnectionString="<%$ ConnectionStrings:picDataBaseConnectionString1 %>"

                SelectCommand="SELECT * FROM [picTable]"></asp:SqlDataSource>

            <%-- DataSource: sqlDsParam --%>

            <asp:SqlDataSourceID="sqlDsParam"runat="server"ConnectionString="<%$ConnectionStrings:picDataBaseConnectionString1 %>"

            DeleteCommand="DeleteByID" DeleteCommandType="StoredProcedure"

            SelectCommand="StoredProcedureWithParam" SelectCommandType="StoredProcedure">

                <DeleteParameters>

                    <asp:ControlParameter ControlID ="gvParam" Name ="id" PropertyName ="SelectedValue" Type ="int32" />

                </DeleteParameters>

                <SelectParameters>

                    <asp:ControlParameter ControlID="txtID" Name="pId" PropertyName="Text" Type="Int32" />

                </SelectParameters>

            </asp:SqlDataSource>

        </div>

        </form>

    </body>

    </html>


    转载地址:http://microphoenix.spaces.live.com/blog/cns!cae32c6a59c74431!268.entry

  • 相关阅读:
    VS2010 MFC对话框程序用CButtonST给按钮添加图标
    VS2010 MFC 使用GDI+给图片添加汉字
    C++ Primer(第4版)-学习笔记-第2部分:容器和算法
    C++ 面向对象编程
    C++类(Class)总结
    delegate、notification、KVO场景差别
    iOS block种类和切换
    Copy 与MutableCopy的区别
    ios 避免循环引用
    WKInterfaceImage 无法更新图片的问题
  • 原文地址:https://www.cnblogs.com/yiki/p/615458.html
Copyright © 2011-2022 走看看