Wrox Programmer Forums
|
BOOK: Professional ASP.NET 1.0, Special Edition/1.1
This is the forum to discuss the Wrox book Professional ASP.NET 1.1 by Alex Homer, Dave Sussman, Rob Howard, Brian Francis, Karli Watson, Richard Anderson; ISBN: 9780764558900
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 1.0, Special Edition/1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 19th, 2007, 02:14 AM
Registered User
 
Join Date: Jun 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem in add totals in datagrid

hi,
I have this asp.net script that supposed to get total of
records.But when i run it i get this error.
System.FormatException: Input string was not in a correct format.

Source Error:



Line 310: calctotal(e.Item.Cells(3).Text)
Line 311: e.Item.Cells(3).Text = String.Format("{0:n}", Convert.ToDouble(e.Item.Cells(3).Text))
Line 312:
Line 313: ElseIf (e.Item.ItemType = ListItemType.Footer) Then

i get null value at this line Response.Write(e.Item.Cells(3).Text).can anybody tell me how to fix it?

here is code

Partial Class first
Inherits System.Web.UI.Page

Private rtotal As Double = 0
'protected DataGrid DataGrid1
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


Dim s, s2, fyear As String

s = (Request.QueryString("strtxt"))
Response.Write(s)
fyear = (Request.QueryString("strtxt2"))
Response.Write(fyear)
fyear = "20072008"
'Dim strTxtTransfer As String = Request.QueryString("strTxt")
'Response.Write(strTxtTransfer)
Dim sql_str, sqls As String

If Mid(s, 1, 2) = "TO" Then
sql_str = "Select t.store_invoice_no Inv,c.customer_name customer, to_char(t.invoice_date,'dd/mm/yyyy')inv_dat, t.store_item_pcs pcs, t.store_item_tot_pcs tot_pcs, nvl(t.no_of_packets,1) packets from ho_store_transaction t, customer_master c where store_challan_no= '" & s & "' and t.store_customer_code=c.customer_code and t.store_financial_year_code ='" & fyear & "' and t.store_company_code='DD' and t.store_location_code='L020' UNION Select '','', 'Total',sum(t.store_item_pcs)t_qty1, sum(t.store_item_tot_pcs)t_pcs1, sum(t.no_of_packets)t_packets from ho_store_transaction t, customer_master c where store_challan_no= '" & s & "' and t.store_customer_code=c.customer_code and t.store_financial_year_code ='" & fyear & "' and t.store_company_code='DD' and t.store_location_code='L020'"
Else
'ElseIf Mid(s, 1, 1) = "R" Then

sql_str = "Select m.store_challan_no Inv, c.customer_name customer, to_char(m.store_challan_date,'dd/mm/yyyy')inv_dat, sum(t.store_item_pcs)pcs, sum(t.store_item_tot_pcs)tot_pcs, nvl(t.no_of_packets,1) packets from ho_store_master m, ho_store_transaction t,customer_master c where m.Store_trfout_flag='N' and m.store_challan_no = t.store_challan_no and m.store_customer_code = c.CUSTOMER_CODE and m.store_challan_no = '" & s & "' and to_char(m.store_challan_date,'dd/mm/yyyy')= to_char(t.store_challan_date,'dd/mm/yyyy') and m.store_financial_year_code='" & fyear & "' and m.store_company_code='DD' and m.store_location_code='L020' group by m.store_challan_no,m.store_challan_date,c.customer _name,t.no_of_packets UNION Select '', '', 'Total', sum(t.store_item_pcs)t_qty1, sum(t.store_item_tot_pcs)t_pcs1, nvl(sum(t.no_of_packets),1)t_packets from ho_store_master m, ho_store_transaction t,customer_master c where m.Store_trfout_flag='N' and m.store_challan_no = t.store_challan_no and m.store_customer_code = c.CUSTOMER_CODE and m.store_challan_no = '" & s & "' and to_char(m.store_challan_date,'dd/mm/yyyy')= to_char(t.store_challan_date,'dd/mm/yyyy') and m.store_financial_year_code='" & fyear & "' and m.store_company_code='DD' and m.store_location_code='L020' group by m.store_challan_no,m.store_challan_date,c.customer _name,t.no_of_packets"
End If

Dim str As String
Dim con As OracleConnection

str = "User Id=nfc;Password=nfc;Data Source=dh"
con = New OracleConnection(str)
con.Open()

Dim cmd As New OracleDataAdapter _
(sql_str, con)

Dim ds As Data.DataSet = New Data.DataSet()
cmd.Fill(ds, "ho_store_transaction")

'ds.Merge(ds2)


DataGrid1.DataSource = ds.Tables("ho_store_transaction")
DataGrid1.DataBind()


End Sub

Protected Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound

If (e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem) Then

Response.Write(e.Item.Cells(3).Text)

calctotal(e.Item.Cells(3).Text)
e.Item.Cells(3).Text = String.Format("{0:n}", Convert.ToDouble(e.Item.Cells(3).Text))

ElseIf (e.Item.ItemType = ListItemType.Footer) Then
e.Item.Cells(2).Text = "TOTAL:"
e.Item.Cells(3).Text = String.Format("{0:n}", rtotal)


End If



End Sub
Private Sub calctotal(ByVal _pcs As String)

If IsNumeric(_pcs) Then
Response.Write(_pcs)
rtotal += Double.Parse(_pcs)
End If
End Sub
End Class

please help.

thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
datagrid add table cells problem keyvanjan ASP.NET 1.0 and 1.1 Basics 2 August 9th, 2006 11:55 PM
How to add to datagrid without database annsary ASP.NET 1.0 and 1.1 Professional 17 April 3rd, 2006 08:44 PM
SSRS 2005 Matrix Totals Problem!!!!!!!!!!!!!!!!! dba123 Reporting Services 1 February 10th, 2006 10:00 AM
How to add rows in DataGrid ? vivekian ASP.NET 1.0 and 1.1 Professional 0 March 13th, 2005 04:30 AM
How to add rows in DataGrid ? vivekian ASP.NET 1.0 and 1.1 Basics 0 March 13th, 2005 04:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.