?
Solved

Labels Not Updating After GridView has changed

Posted on 2009-04-29
3
Medium Priority
?
401 Views
Last Modified: 2012-05-06
I have a web page that has a gridview on it.  The gridview allows for editing, updating and deleting records.  I have two labels that appear outside the gridview that inform the user as to whether the gridview is or isn't in balance over has to many lines.  Currently, I have the code attached to a submit button which fires correctly, but only when you hit the submit button which is only used to call the transaction.  Also if I use GridView1.Databind() on the page load it causes my footer in the GridView to double the dollar that the transaction is off.  The transaction is to net to zero.

So the 500 Point question is how do I fire those labels without using the submit button each time after a row has been updated.

Just so you know I am using a standard VS 2005, canned GridView with the ShowEdit and ShowDelete buttons, so nothing fancy.
ASPX Page:
<br />
<div style="text-align:center"><asp:Label Text="1st WARNING" ForeColor="red" Font-Bold="true" Visible="false" ID="Warning" runat="server" /></div>
<div style="text-align:center"><asp:Label Text="2nd WARNING" ForeColor="red" Font-Bold="true" Visible="false" ID="Warning2" runat="server" /></div>
 
ASPX.VB Code - Submit Button
 
    Protected Sub SubmitBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SubmitBtn.Click
 
        GridView1.DataBind()
 
        RowCount.Text = GridView1.Rows.Count
 
        If CType(RowCount.Text, Integer) > 50 Or GetTotal() <> "0.00" Then
            IndexBtn.Visible = False
            Warning.Visible = True
            Warning.Text = ("THE TRANSACTION IS EITHER OUT OF BALANCE OR EXCEEDS 50 LINES," _
            & " CHECK THE TOTAL AND NUMBER OF RECORDS IN THE GRID!!!")
        Else
            IndexBtn.Visible = True
            Warning.Visible = False
        End If
 
    End Sub

Open in new window

0
Comment
Question by:gagnonmv
  • 2
3 Comments
 
LVL 10

Expert Comment

by:Christian de Bellefeuille
ID: 24265587
Why don't you try to use the RowDataBound or DataBound events of your gridview to update theses labels?
0
 
LVL 10

Accepted Solution

by:
Christian de Bellefeuille earned 2000 total points
ID: 24265591

    Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        RowCount.Text = GridView1.Rows.Count
 
        If CType(RowCount.Text, Integer) > 50 Or GetTotal() <> "0.00" Then
            IndexBtn.Visible = False
            Warning.Visible = True
            Warning.Text = ("THE TRANSACTION IS EITHER OUT OF BALANCE OR EXCEEDS 50 LINES," _
            & " CHECK THE TOTAL AND NUMBER OF RECORDS IN THE GRID!!!")
        Else
            IndexBtn.Visible = True
            Warning.Visible = False
        End If
    End Sub

Open in new window

0
 

Author Closing Comment

by:gagnonmv
ID: 31576212
Awesome, It worked, Thank you
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question