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

  • 相关阅读:
    curd_4
    curd_2
    Python Regex库的使用
    Python Assert 确认条件为真的工具
    Python Regex库的使用(2)
    Python lambda的用法
    Python 列表综合
    with ss(date,date2) (select * from sysdummy1) select * from ss
    延迟执行函数
    ObjectiveC 的基本数据类型、数字、字符串和集合等介绍
  • 原文地址:https://www.cnblogs.com/yiki/p/615458.html
Copyright © 2011-2022 走看看