473,772 Members | 2,244 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

total count of records in gridview row data bound

8 New Member
Expand|Select|Wrap|Line Numbers
  1.  
  2. Imports System.Data
  3. Imports System.Data.SqlClient
  4. Imports System.Data.OracleClient
  5. Imports CrystalDecisions.CrystalReports.Engine
  6. Imports CrystalDecisions.Shared
  7. Imports System.Globalization
  8. Partial Class plaza_dailyDeclareExcessShort
  9.     Inherits System.Web.UI.Page
  10.     Private Report1 As ReportDocument
  11.     Private OraCon2 As New OracleConnection(ConfigurationManager.AppSettings("OraCon2"))
  12.     Private sqlCon As New SqlConnection(ConfigurationManager.AppSettings("SQLCon"))
  13.     Private selectCmd, selectCmd2, selectCmd4 As String
  14.     Private selectCmd3, selectAdp As OracleDataAdapter
  15.     Private sqlCom, sqlCom2, sqlCom3, sqlCom4 As OracleCommand
  16.     Private sqlCom1 As String
  17.     Private ora As New OracleHandler
  18.     Dim ds As New DataSet
  19.     Dim value1 As String
  20.     Dim paid, unpaid, excess As Decimal
  21.     Dim sumExcess As Decimal = 0
  22.     Dim sumPaid As Decimal = 0
  23.     Dim sumUnpaid As Decimal = 0
  24.     Dim i As Integer = 0
  25.     Dim j As Integer = 0
  26.     Dim k As Integer = 0
  27.     Dim lblerror As Label
  28.     Private checkpriv As New getaccesspriv()
  29.     Private priv1, priv2, priv3, priv4, loginid As String
  30.     Private privval As Integer
  31.     Private priv As AccessPriv = New AccessPriv()
  32.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  33.         'ddlPlazano.Text = Session("plazano").ToString()
  34.         'txtCalendar1.Text = Date.Today.ToShortDateString()
  35.         If Not Page.IsPostBack Then
  36.             'chkpriv()
  37.             ' Panel1.Height = ConfigurationManager.AppSettings("PnlNormalH2")
  38.             ds = ora.GetColumnsByCriteria("HQ_PLAZACONSTANT", "HQCS_PLAZAABBREVIATION, HQCS_PLAZANO", "ROWNUM < 2")
  39.             ''ds = Sql.GetTableByColumns("HQ_PLAZACONSTANT", "top(1)HQCS_PLAZAABBREVIATION,HQCS_PLAZANO")
  40.             txtCalendar1.Text = Format(Now, "dd/MM/yyyy") 'Format(Now, "dd/MM/yyyy") 'Date.Today.ToShortDateString()
  41.             Session("date") = txtCalendar1.Text
  42.             'txtAbbr.Text = ds.Tables("HQ_PLAZACONSTANT").Rows(0).Item(0).ToString()
  43.             Session("plazaabbr") = ds.Tables(0).Rows(0).Item(0).ToString()
  44.             Session("noplaza") = ds.Tables(0).Rows(0).Item(1).ToString()
  45.  
  46.         End If
  47.     End Sub
  48.     Sub chkpriv()
  49.         If Not Session("loginid") Is Nothing Then
  50.  
  51.             loginid = Session("loginid").ToString()
  52.             priv = getaccesspriv.checkpriv(loginid, "P401")
  53.  
  54.             If priv.access1 = False Then 'check page authorization
  55.                 Session("progname") = "P401"
  56.                 Response.Redirect("~/cannotaccess.aspx")
  57.             End If
  58.             If priv.access2 = False Then 'check report authorization
  59.                 'Button1.Enabled = False
  60.                 GridView3.Columns(12).Visible = False
  61.             End If
  62.  
  63.         End If
  64.     End Sub
  65.     Protected Sub btnQuery_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnQuery.Click
  66.  
  67.         lblerror = Master.FindControl("lblerror")
  68.         lblerror.Text = ""
  69.         Try
  70.  
  71.             Session("date") = txtCalendar1.Text
  72.             Session("noplaza") = ddlPlazano.SelectedItem.Text
  73.             Session("plazaabbr") = ddlPlazano.SelectedValue
  74.  
  75.  
  76.             sqlCom1 = "  SELECT DISTINCT HQ_CASHRECONCILEHEADER.HQRH_BADGENO, HQ_CASHRECONCILEHEADER.HQRH_SHIFT, HQ_BADGE.HQBD_BADGENAME," & _
  77.                      " Case sign(HQ_CASHRECONCILEHEADER.HQRH_DISCRRECONCILE)   when 1 then HQRH_DISCRRECONCILE when -1 then 0 " & _
  78.                      " end as  HQRH_DISCRRECONCILE ," & _
  79.                      " case sign (hqrh_adjustamount) when 1 then hqrh_adjustamount  " & _
  80.                     " when -1 then 0  end as hqrh_adjustamount," & _
  81.                    " case sign(hqrh_discradjustment) when -1 then (hqrh_discradjustment * -1) " & _
  82.                   " end as hqrh_discradjustment " & _
  83.                   " FROM HQ_CASHRECONCILEHEADER, HQ_BADGE WHERE HQ_CASHRECONCILEHEADER.HQRH_PLAZANO = HQ_BADGE.HQBD_PLAZANO " & _
  84.                  " AND HQ_CASHRECONCILEHEADER.HQRH_BADGENO = HQ_BADGE.HQBD_BADGENO AND (HQ_BADGE.HQBD_REVISIONNUMBER = (SELECT MAX(HQBD_REVISIONNUMBER) AS EXPR1 " & _
  85.                  "  FROM HQ_BADGE HQ_BADGE_1 WHERE (HQBD_PLAZANO = '" & Session("noplaza") & "') AND (HQBD_BADGENO IN (SELECT DISTINCT HQRH_BADGENO " & _
  86.                 " FROM HQ_CASHRECONCILEHEADER HQ_CASHRECONCILEHEADER_1 WHERE HQRH_OPERATIONALDATE =TO_DATE( '" & Session("date") & "','DD/MM/YYYY') " & _
  87.                 " AND(HQRH_PLAZANO = '" & Session("noplaza") & "'))))) AND HQRH_OPERATIONALDATE =TO_DATE( '" & Session("date") & "','DD/MM/YYYY')  " & _
  88.                " AND (HQ_CASHRECONCILEHEADER.HQRH_PLAZANO = '" & Session("noplaza") & "')"
  89.  
  90.             SqlDataSource4.SelectCommand = sqlCom1
  91.             GridView3.DataSource = SqlDataSource4
  92.             GridView3.DataBind()
  93.             GridView3.Visible = True
  94.  
  95.         Catch ex As Exception
  96.  
  97.             lblerror.Text = ex.Message ' "Operational date must be in 'dd/mm/yyyy' format. "
  98.         End Try
  99.     End Sub
  100.     Protected Sub ddlPlazano_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlPlazano.SelectedIndexChanged
  101.         txtAbbr.Text = ddlPlazano.SelectedValue.ToString()
  102.         Session("plazaabbr") = txtAbbr.Text
  103.     End Sub
  104.     Protected Sub PopCalendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles PopCalendar1.SelectionChanged
  105.         'txtCalendar1.Text = PopCalendar1.SelectedDate.ToString()
  106.         txtCalendar1.Text = Format(PopCalendar1.DateValue, "dd/MM/yyyy").ToString()
  107.         Session("date") = txtCalendar1.Text
  108.  
  109.     End Sub
  110.     Protected Sub GridView3_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView3.RowCommand
  111.         If e.CommandName = "select" Then
  112.  
  113.             Dim index As Integer = Convert.ToInt32(e.CommandArgument)
  114.  
  115.             Dim badge As String = CType(GridView3.Rows(index).FindControl("lblBadgeNo"), Label).Text
  116.             Dim oper As String = txtCalendar1.Text 'CType(GridView1.Rows(index).FindControl("lblOperationalDate"), Label).Text
  117.             Dim badgename As String = CType(GridView3.Rows(index).FindControl("lblbadgename"), Label).Text
  118.             Dim shift As String = CType(GridView3.Rows(index).FindControl("lblshift"), Label).Text
  119.             Dim discrreconcile As String = CType(GridView3.Rows(index).FindControl("lbldiscrreconcile"), Label).Text
  120.             Dim adjustamount As String = CType(GridView3.Rows(index).FindControl("lbladjustamount"), Label).Text
  121.             Dim discradjustment As String = CType(GridView3.Rows(index).FindControl("lbldiscradjustment"), Label).Text
  122.  
  123.             Session("noplaza") = ddlPlazano.SelectedItem.Text
  124.             Session("plazaabb") = ddlPlazano.SelectedValue
  125.  
  126.             Dim plazano As String = ddlPlazano.SelectedItem.Text
  127.  
  128.             Response.Redirect("/" + ConfigurationManager.AppSettings("foldername") + "/rplaza/DailyDeclarationExcessShort.aspx?badge=" & badge & "&oper=" & oper & "&badgename=" & badgename & "&shift=" & shift & "&discrreconcile=" & discrreconcile & "&adjustamount=" & adjustamount & "&discradjustment=" & discradjustment & "&plazano=" & plazano)
  129.         End If
  130.  
  131.     End Sub
  132.     Protected Sub GridView3_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView3.RowCreated
  133.         If e.Row.RowType = DataControlRowType.DataRow Then
  134.             'CType(e.Row.FindControl("LinkDetails"), LinkButton).CommandArgument = e.Row.RowIndex.ToString()
  135.  
  136.         End If
  137.     End Sub
  138.     Protected Sub GridView3_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView3.RowDataBound
  139.         If e.Row.RowType = DataControlRowType.DataRow Then
  140.  
  141.             excess = IIf((DataBinder.Eval(e.Row.DataItem, "HQRH_DISCRRECONCILE")) Is DBNull.Value, "0.00", (DataBinder.Eval(e.Row.DataItem, "HQRH_DISCRRECONCILE")))
  142.             paid = IIf((DataBinder.Eval(e.Row.DataItem, "HQRH_ADJUSTAMOUNT")) Is DBNull.Value, "0.00", (DataBinder.Eval(e.Row.DataItem, "HQRH_ADJUSTAMOUNT")))
  143.             unpaid = IIf((DataBinder.Eval(e.Row.DataItem, "HQRH_DISCRADJUSTMENT")) Is DBNull.Value, "0.00", (DataBinder.Eval(e.Row.DataItem, "HQRH_DISCRADJUSTMENT")))
  144.  
  145.             sumExcess = sumExcess + excess
  146.             sumPaid = sumPaid + paid
  147.             sumUnpaid = sumUnpaid + unpaid
  148.  
  149.             'CType(e.Row.Cells(2).FindControl("label45"), Label).Text = Format(excess, "0.00")
  150.             'CType(e.Row.Cells(3).FindControl("label1"), Label).Text = Format(paid, "0.00")
  151.             'CType(e.Row.Cells(3).FindControl("label5"), Label).Text = Format(unpaid, "0.00")
  152.  
  153.         ElseIf e.Row.RowType = DataControlRowType.Footer Then
  154.  
  155.             '          if (gvFooterSample.Rows[0].Cells[1].Text == "No records found") 
  156.             'e.Row.Cells[0].Text="Total No of rows: "+Convert.ToString((gvFooterSample.Rows.Count)-1);
  157.  
  158.             '            Else
  159.  
  160.             'e.Row.Cells[0].Text = "Total No of rows: " + Convert.ToString(gvFooterSample.Rows.Count); 
  161.  
  162.             CType(e.Row.Cells(3).FindControl("Label46"), Label).Text = GridView3.Rows.Count.ToString
  163.             CType(e.Row.Cells(4).FindControl("Label43"), Label).Text = GridView3.Rows.Count.ToString
  164.             CType(e.Row.Cells(4).FindControl("Label22"), Label).Text = GridView3.Rows.Count.ToString
  165.  
  166.             'e.Row.Cells(0).Text = "Totals:"
  167.  
  168.             CType(e.Row.Cells(3).FindControl("Label47"), Label).Text = Format(sumExcess, "0.00")
  169.             CType(e.Row.Cells(4).FindControl("Label44"), Label).Text = Format(sumPaid, "0.00")
  170.             CType(e.Row.Cells(4).FindControl("Label4"), Label).Text = Format(sumUnpaid, "0.00")
  171.  
  172.         End If
  173.  
  174.     End Sub
  175.  
  176.     Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnreport.Click
  177.         lblerror = Master.FindControl("lblerror")
  178.         lblerror.Text = ""
  179.         Try
  180.             Dim d1 As Date = Date.ParseExact(txtCalendar1.Text, "dd/MM/yyyy", New CultureInfo("fr-FR", True))
  181.             'txtCalendar1.Text = PopCalendar1.SelectedDate.ToString()
  182.             Session("date") = txtCalendar1.Text
  183.             Session("noplaza") = ddlPlazano.SelectedItem.Text
  184.             Session("plazaabb") = ddlPlazano.SelectedValue
  185.             'txtCalendar1.Text = ""
  186.             Response.Redirect("~/rplaza/DailyDeclarationExcessShort.aspx")
  187.         Catch
  188.             lblerror.Text = "Operational date must be in 'dd/mm/yyyy' format. "
  189.         End Try
  190.     End Sub
  191.  
  192. End Class
  193.  
  194.  



Hi,
i need to count the records in row data bound.
but in my db some rows have 0 values
here i no need to count the 0 or empty rows
i need to count only >0 values

for example

A B C

1 0 2
0 1 0
2 3 empty

2 2 1 -> TotalCount


like this i need.
is it possible
any one plz suggest me


Thanks in advance.
Oct 6 '10 #1
0 1952

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3649
by: Tracey | last post by:
in my procedure, I want to count the number of rows that have errored during an insert statement - each row is evaluated using a cursor, so I am processing one row at a time for the insert. My total count to be displayed is inside the cursor, but after the last fetch is called. Wouldn't this display the last count? The problem is that the count is always 1. Can anyone help? here is my code, .... cursor fetch
0
1116
by: Paul | last post by:
I have a data bound form to which I wish to add a new row of data using c#. (SQL Server database accessed with Stored Procedures using SQLClient) If I try to add a new row for a user, I can add a new row using code like this. DataRow newRow = this.dsetContract.dcl_fsubContractDelivery.NewRow(); newRow = this.ContractID;
2
4635
by: | last post by:
Hi all, I have a gridview control with a bound field as outlined below. The problem is that the formatting is not happening. The data gets rendered as 12999.0000. It is being stored in a decimal data type. Any ideas? <asp:boundfield headertext="Amount" datafield="amount" dataformatstring="{0:C}"/> TIA!
4
2616
by: Nalaka | last post by:
Hi, I have two questions about gridViews. 1. How can I intercept the row/column values at loading to change values? 2. After I update a row (using default update functionality), how can I re-format the updated row fields. I have looked at gridView.rowUpdated method, but cannot figure out how....
2
1872
by: ibiza | last post by:
Hi, well, I'd like to know how to still display the footer of a gridview even if there is no data bound from the db. That is because I use the footer to put my inputs to add a new record, so I need to be able to add records, even if there is none yet... thanks!
0
2216
by: mjsterz | last post by:
I've been working with VB .NET for less than a year and this is the first time I've posted on one of these groups, so let me apologize beforehand if I'm being unclear, not posting my issue correctly, posting to the wrong forum, or committing some other sort of faux pas. My team is developing a Windows Forms application using VS 2005 with SQL Server 2005 on the back end and we're having a problem using ComboBoxes data bound to lookup...
2
4525
by: gmccallum | last post by:
I have a data entry screen using controls bound through a bindingSource, TableAdaptor and a BindingNavigator to move through the records. When I have an data entry error (such as Null for a value) I get the following error raised all the way to the App.Run command. This is not a dataGridView, so I can not use that DataError event to catch it. I have tried the BindingSource_DataError event, but that does not seem to get fired. There is...
1
4467
by: JustinCarmony | last post by:
I'm using a DataAdapter to fill a DataSet to display a list of items in a custom way. I'm not using the GridView or any server controls like that. This is my code: <code> SqlConnection sqlConn = DatabaseControl.Database.GetConnection(Globals.dbConn); SqlCommand cmdTitles = new SqlCommand(); cmdTitles.CommandText = "SelectTitlesByCategory";
1
1918
by: crystalgal | last post by:
Help. I am using Excel to enter in daily numbers in worksheet 2. I want to use vb (w/in excel) to create a command button in worksheet 1. I want to enter a date in a cell and click the command button. I then want to use the date i entered into the cell to sum the total of numbers from worksheet 2 by filtering the numbers by the date. I want to enter 7/15/2007. I want to return the total count of all "Reg" jobs somewhere on worksheet 1 ...
3
1648
by: cr113 | last post by:
I'm trying to convert a windows app to ASP.NET using VS2005. I have some web experience, but not much. 99% of the time if I need to display data in a table in my windows apps I use a ListView object and populate it manually using code like this: ListView1.Items.Add("Jones") ListView1.Items(ListView1.Items.Count - 1).SubItems.Add("123") The result of this code would be a row added to the ListView like this:
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10104
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9912
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8934
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6715
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.