Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 19th, 2007, 02:14 AM
Registered User
 
Join Date: Jun 2007
Location: , , .
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

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 09:00 AM
How to add rows in DataGrid ? vivekian ASP.NET 1.0 and 1.1 Professional 0 March 13th, 2005 03:30 AM
How to add rows in DataGrid ? vivekian ASP.NET 1.0 and 1.1 Basics 0 March 13th, 2005 03:28 AM



All times are GMT -4. The time now is 05:23 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.