我有ASP.net
个C#
网络应用有问题。在应用程序上,用户可以输入一些数据并单击"添加"按钮。这将在屏幕上生成一个网格,其中包含用户刚刚输入的数据。还有一个文本框,用于"要求的总金额"。在此之下,有一个标签为"剩余金额"。如果用户在"请求的总金额中放入100.00"然后将75.00加载到网格中,剩余金额为"剩余金额"将显示" 25.00"。这很好用。我在网格中添加了删除行,因此用户可以删除特定的行。这也有效。我在网格中添加了一个_RowDeleted函数,然后插入函数来计算"剩余金额"。这是问题所在:
当我删除该行时,它会从数据库中删除,没有问题。但是,屏幕上的标签不会刷新。我在代码中停了一下,然后走了过去。该脚本工作,label.text加载了我期望的,但它只是在屏幕上刷新。我尝试了很多不同的东西,但一直在撞墙。任何帮助将不胜感激!
网格:
<dx:ASPxGridView ID="gridGL1" runat="server" AutoGenerateColumns="False"
DataSourceID="sdsGLData" KeyFieldName="GenLedgerID" OnRowDeleted="gridGL1_RowDeleted">
<Columns>
<dx:GridViewCommandColumn VisibleIndex="0" Caption=" " ButtonType="Button">
<DeleteButton Visible="True">
</DeleteButton>
</dx:GridViewCommandColumn>
<dx:GridViewDataTextColumn FieldName="GenLedgerID" Visible="false" VisibleIndex="1">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="UnitNumber" VisibleIndex="2">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="AccountNumber" VisibleIndex="3">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Amount" VisibleIndex="4">
</dx:GridViewDataTextColumn>
</Columns>
<SettingsBehavior ConfirmDelete="True" />
</dx:ASPxGridView>
SDS:
<asp:SqlDataSource ID="sdsGLData" runat="server"
ConnectionString="<%$ ConnectionStrings:FEAPConnectionString %>"
ProviderName="<%$ ConnectionStrings:FEAPConnectionString.ProviderName %>"
SelectCommand="prcRequestGLList" SelectCommandType="StoredProcedure"
DeleteCommand="delete RequestsGL where GenLedgerID = @GenLedgerID">
<SelectParameters>
<asp:Parameter Direction="ReturnValue" Name="RETURN_VALUE" Type="Int32" />
<asp:ControlParameter ControlID="lblUserID" Name="UserID" PropertyName="Text"
Type="String" />
<asp:ControlParameter ControlID="txtRequestDate" Name="RequestDate"
PropertyName="Text" Type="DateTime" />
</SelectParameters>
</asp:SqlDataSource>
_RowDeleted
protected void gridGL1_RowDeleted(object sender, DevExpress.Web.Data.ASPxDataDeletedEventArgs e)
{
RemainingTotal();
}
RemainingTotal():
protected void RemainingTotal()
{
TotalGLAmount();
decimal TotalReq;
decimal TotalGL;
// Total Requested Amount
if (txtTotalAmount.Text == "")
{
TotalReq = 0.00M;
}
else
{
TotalReq = Convert.ToDecimal(txtTotalAmount.Text);
}
// Total GL Amount
if (lblTotalGLAmount.Text == "")
{
TotalGL = 0.00M;
}
else
{
TotalGL = Convert.ToDecimal(lblTotalGLAmount.Text);
}
// Total Remaining Amount
if (TotalReq != TotalGL)
{
lblRemainingAmount.Text = Convert.ToString(TotalReq - TotalGL);
lblTest.Text = Convert.ToString(TotalReq - TotalGL);
if (TotalReq > TotalGL)
{
lblRemainingAmount.ForeColor = Color.Black;
}
else if (TotalReq < TotalGL)
{
lblRemainingAmount.ForeColor = Color.Red;
}
}
else
{
if (txtTotalAmount.Text != "")
{
lblRemainingAmount.Text = "<b>EVEN!</b>";
lblRemainingAmount.ForeColor = Color.Black;
lblTest.Text = "<b>EVEN!</b>";
}
else
{
lblRemainingAmount.Text = "0.00";
lblRemainingAmount.ForeColor = Color.Black;
lblTest.Text = "0.00";
}
}
}