我有一个工作的gridview和sqldatasource,带有select和updatecommand。然后我将命令类型更改为存储过程(显然是命令名),在sproc中有一些更强大的逻辑。
当我从SQL窗口运行它时它起作用但现在当我编辑gridview行时,更新链接什么都不做。我可以点击编辑并取消就好了,但更新已经死了。没有错误,没有动作,没有。这是我以前的旧数据源:
<asp:SqlDataSource ID="sqlThresholdsProjected" runat="server" ConnectionString="<%$ ConnectionStrings:tmus_bill %>"
SelectCommand="sp_BillingThresholdsGet" SelectCommandType="StoredProcedure"
UpdateCommand="UPDATE DiscountTiers SET Discount = @Discount, Min = @Min, Max = @Max WHERE DiscountTiersID = @DiscountTiersID">
<SelectParameters>
<asp:ControlParameter ControlID="ddlYear" DbType="Decimal" Name="year" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="Min" />
<asp:Parameter Name="Max" />
<asp:Parameter Name="Discount" />
<asp:Parameter Name="DiscountTiersID" />
</UpdateParameters>
</asp:SqlDataSource>
新的SqlDataSource:
<asp:SqlDataSource ID="sqlThresholdsProjected" runat="server" ConnectionString="<%$ ConnectionStrings:tmus_bill %>"
SelectCommand="sp_BillingThresholdsGet" SelectCommandType="StoredProcedure"
UpdateCommand="spu_FeeThresholds" UpdateCommandType="StoredProcedure" DataSourceMode="DataReader">
<SelectParameters>
<asp:ControlParameter ControlID="ddlYear" DbType="Decimal" Name="year" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="Min" />
<asp:Parameter Name="Max" />
<asp:Parameter Name="Discount" />
<asp:Parameter Name="DiscountTiersID" />
</UpdateParameters>
</asp:SqlDataSource>
gridview:
<asp:UpdatePanel runat="server" ID="udpThresholds">
<ContentTemplate>
<asp:GridView ID="gvThresholdsProjected" runat="server" AutoGenerateColumns="False"
DataKeyNames="DiscountTiersID" DataSourceID="sqlThresholdsProjected" AllowSorting="false"
EditRowStyle-BackColor="GreenYellow" RowStyle-HorizontalAlign="Right">
<AlternatingRowStyle BackColor="#FFFFCC" />
<Columns>
<asp:BoundField DataField="DiscountTiersID" HeaderText="DiscountTiersID"
InsertVisible="False" ReadOnly="True" Visible="false" />
<asp:BoundField DataField="Min" HeaderText="Min" DataFormatString="{0:C}" ControlStyle-Width="50px" />
<asp:BoundField DataField="Max" HeaderText="Max" DataFormatString="{0:C}" ControlStyle-Width="50px" />
<asp:BoundField DataField="Discount" HeaderText="Discount" DataFormatString="{0:N2}%" ControlStyle-Width="30px" />
<asp:TemplateField HeaderText="Year">
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("Year") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" />
</Columns>
<HeaderStyle BackColor="#336699" ForeColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="sqlThresholdsProjected" runat="server"
ConnectionString="<%$ ConnectionStrings:tmus_bill %>"
SelectCommand="sp_BillingThresholdsGet" SelectCommandType="StoredProcedure"
UpdateCommand="spu_FeeThresholds" UpdateCommandType="StoredProcedure" DataSourceMode="DataReader">
<SelectParameters>
<asp:ControlParameter ControlID="ddlYear" DbType="Decimal" Name="year" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="Min" />
<asp:Parameter Name="Max" />
<asp:Parameter Name="Discount" />
<asp:Parameter Name="DiscountTiersID" />
</UpdateParameters>
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
感谢您提供的任何帮助。
答案 0 :(得分:0)
试着在这里猜测。 DataSourceMode必须是DataSet才能获得双向数据绑定。 DataReader只是一个“读者”。