473,394 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

total count of records in gridview row data bound

8
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 1926

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

Similar topics

1
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...
0
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...
2
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...
4
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...
2
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...
0
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...
2
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)...
1
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...
1
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...
3
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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...
0
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...

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.