Check these threads:
ASPxGridView - How to update an external control during a callback
Question
I have an ASP.net
with C#
web app with an issue. On the app, the user can enter some data and click an "Add" button. This will generate a grid on the screen with the data the user just entered. There is also a text box for "Total Amount Requested". Below that, there is a label for "Remaining Amount". If the user puts 100.00 in the "Total Amount Requested" and then loads 75.00 into the grid, the "Remaining Amount" will show "25.00". This works fine. I added a delete row to the grid, so the user can delete specific rows. This also works. I added a _RowDeleted function to the grid, and then inserted the function to do the math for "Remaining Amount". Here is the issue:
When I delete the row, it deletes from the database, no issue. However, the label on the screen does not refresh. I put a stop in the code and walked through it. The script works, the label.text is loaded with what I expect, but it just won't refresh on screen. I've tried many different things but keep hitting a wall. Any help would be appreciated!
The Grid:
<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>
The 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>
The _RowDeleted
protected void gridGL1_RowDeleted(object sender, DevExpress.Web.Data.ASPxDataDeletedEventArgs e)
{
RemainingTotal();
}
The 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";
}
}
}