none
sqldatasource和它的参数,以及是如何传递的问题。黑体注释要去掉才能运行个。 RRS feed

  • 问题

  •   <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues" //ConflictDetection是啥?
                ConnectionString="<%$ ConnectionStrings:pubconn %>" DeleteCommand="DELETE FROM [authors] WHERE [au_id] = @original_au_id AND [city] = @original_city" //@original_au_id是指啥?哪里来的?
                InsertCommand="INSERT INTO [authors] ([au_id], [city]) VALUES (@au_id, @city)"
                OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [au_id], [city] FROM [authors] ORDER BY [au_id]"  <--original {0}是占哪个的占位符啊-->
                UpdateCommand="UPDATE [authors] SET [city] = @city WHERE [au_id] = @original_au_id AND [city] = @original_city">
                <DeleteParameters>
                    <asp:Parameter Name="original_au_id" Type="String" />
                    <asp:Parameter Name="original_city" Type="String" />
                </DeleteParameters>
                <UpdateParameters>
                    <asp:Parameter Name="city" Type="String" />
                    <asp:Parameter Name="original_au_id" Type="String" />///这里的Parameter Name 有啥用?可以打乱顺序么?
                    <asp:Parameter Name="original_city" Type="String" />
                </UpdateParameters>
                <InsertParameters>
                    <asp:Parameter Name="au_id" Type="String" />
                    <asp:Parameter Name="city" Type="String" />
                </InsertParameters>
            </asp:SqlDataSource>
            <br />
            <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
                AutoGenerateColumns="False" CellPadding="4" DataKeyNames="au_id" DataSourceID="SqlDataSource1"  ///DataKeyNames做啥用?
                ForeColor="#333333" GridLines="None">
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <Columns>
                    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowSelectButton="True" />
                    <asp:BoundField DataField="au_id" HeaderText="au_id" ReadOnly="True" SortExpression="au_id" />   ///DataField做啥用啊
                    <asp:BoundField DataField="city" HeaderText="city" SortExpression="city" />
                </Columns>
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <EditRowStyle BackColor="#999999" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            </asp:GridView>
    <!-- 这里的单击 插入,更新 是怎样与sqldatasouce1通信的呀?要传那些参数,设定哪些参数啊-->
            <br />
            &nbsp;<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:pubconn %>"
                SelectCommand="SELECT * FROM [authors] WHERE ([au_id] = @au_id)">
    <!--这里要传入的@au_id,是哪里传进来的啊,谢谢-->
                <SelectParameters>
                    <asp:ControlParameter ControlID="GridView1" Name="au_id" PropertyName="SelectedValue"  ///PropertyName是啥啊 ,这里的Name 是指啥?麻烦详细说说。
                        Type="String" />
                </SelectParameters>
            </asp:SqlDataSource>
            <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" CellPadding="4"
                DataKeyNames="au_id" DataSourceID="SqlDataSource2" ForeColor="#333333" GridLines="None"   ///dataKeyname是做啥用?
                Height="50px" Width="125px">
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
                <EditRowStyle BackColor="#999999" />
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <Fields>
                    <asp:BoundField DataField="au_id" HeaderText="au_id" ReadOnly="True" SortExpression="au_id" />
                    <asp:BoundField DataField="au_lname" HeaderText="au_lname" SortExpression="au_lname" />
                    <asp:BoundField DataField="au_fname" HeaderText="au_fname" SortExpression="au_fname" />
                    <asp:BoundField DataField="phone" HeaderText="phone" SortExpression="phone" />
                    <asp:BoundField DataField="address" HeaderText="address" SortExpression="address" />
                    <asp:BoundField DataField="city" HeaderText="city" SortExpression="city" />
                    <asp:BoundField DataField="state" HeaderText="state" SortExpression="state" />
                    <asp:BoundField DataField="zip" HeaderText="zip" SortExpression="zip" />
                    <asp:CheckBoxField DataField="contract" HeaderText="contract" SortExpression="contract" />
                </Fields>
                <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            </asp:DetailsView>


    maiyude
    2010年3月6日 3:10

答案