Wrox Programmer Forums
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional 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 February 9th, 2005, 12:37 AM
Registered User
Join Date: Feb 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need help with bound data

I am using a datagrid to display a list of invoices. I would like to add a field for the user to enter a payment amount for one or more of the invoices. The payment field is not in the database. I am new to ASP and cannot figure out how to do this. I have created a datatable with the database fields and this new field and have used it as the datasource for the datagrid. This worked fine and I have use the item template to display the payment field as a textbox. This works fine and the invoices appear correctly in the datagrid. The problem is that I can't figure out how to get the value(s) that are entered in the payment textbox.

The template for the column I want the user to enter the amount in looks like this:

<asp:TemplateColumn HeaderText="Amount">
     <asp:TextBox id="tbxPmtAmount" runat="server" MaxLength="10" Text='<%# DataBinder.Eval(Container, "DataItem.PmtAmount", "{0:F}") %>' Width="100px"></asp:TextBox>

I don't want the user to have to use command buttons for each row. I just want one submit button on the page if that's possible. I'm trying to use this code to retrieve the payment amount:

public sub btnSubmitClick(Sender as Object, e as EventArgs)
     Dim i as Integer
     Dim PmtsEntered As Boolean
     Dim dttInvoices As DataTable
     Dim AmountDue As Single

     PmtsEntered = False

     dttInvoices = Ctype(dtgInvoices.DataSource, DataTable)

     For i = 0 To dttInvoices.Rows.Count - 1
         AmountDue = CType(dttInvoices.Rows(i)("AmountDue"), Single)
         If Trim(dttInvoices.Rows(i)("PmtAmount")) = "" Then
         ElseIf Not IsNumeric(dttInvoices.Rows(i)("PmtAmount")) Then
            lblWrn.Text = "Payment amount must be numeric"
            Exit For
         ElseIf AmountDue And CType(dttInvoices.Rows(i)("PmtAmount"), Single) < 0 Then
            lblWrn.Text = "Payment must be a positive amount"
            PmtsEntered = True
         End If
     If lblWrn.Text = "" And Not PmtsEntered Then
         lblWrn.Text = "No invoices selected for Payment"
     End If

end sub

I am receiving this compile error on the FOR statement:

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. I have no idea what I am doing wrong.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Prefer Not To Use Data-Bound Controls... soundchaser59 ASP.NET 2.0 Basics 1 July 9th, 2007 09:13 PM
Generic Q on data bound program Minos Visual Basic 2005 Basics 1 November 9th, 2006 12:28 PM
Item Data Bound Problem rstelma ASP.NET 1.0 and 1.1 Professional 3 January 25th, 2006 05:39 PM
retrieving a value from data bound to a repeater beeyule General .NET 0 September 8th, 2005 11:59 AM
Data Bound ComboBox joblot VB How-To 0 May 5th, 2004 12:18 AM

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