Databinder.Eval help: Argument 'Expression' is not a valid value. asp.net

I have a page that i'm updating that has several Databinder.Eval on a dataset created in the code behind. I've subsequently added a few more fields of output to the SP, and they show correctly in the dataset on the page when i loop through them.
My page has information on a month by month basis in table 1
The page creates an quarterly aggregate and drops it in table 2 based off of the table 1 dataset.

This is the statement that is bombing it:
Format(DataBinder.Eval(Container, "DataItem.intCancellations"),"###0.")
This same exact statement is being used in an item template with a data list and it works in the first table. When i try and use this same statement, which has all of the same column names in the second datalist it bombs. All of the column names are the same and are of the same format.

the data types in the temporary table here:
dttMonthFirstDay System.DateTime
intNetiUnits System.Int32
intNetDollars System.Int32
intUCUnits System.Int32
intUSUnits System.Double
dblUnitMS System.Double
intMonthID System.Int32
intCancellations System.Int32
intGrossUnits System.Int32

with the data being here, the last digit is cancellations, so for instance this would be January and February, with it creating a partial aggregate record for the two months.
1/1/1950 12:00:00 AM 4 466000 35 54 0.0740740740740741 1
1/1/1950 12:00:00 AM 10 988180 30 76 0.131578947368421 0
========TOTALS: All Values================
1/1/1950 12:00:00 AM 14 1454180 65 130 0.107692307692308 1

here's the stack

Source Error:


Line 316:                                            <tr>
Line 317:                                                <td align="middle">
Line 318:                                                    <asp:Label ID="lblCancellationUnits" runat="server" Text='<%# Format(DataBinder.Eval(Container, "DataItem.intCancellations"),"###0.") %>'></asp:Label></td>
Line 319:                                            </tr>
Line 320:                                                                  <TR>
 


 
ramrodcarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CBeach1980Commented:
Is "========TOTALS: All Values================" one of the values in the dataset?
0
CBeach1980Commented:
If so the problem is with the data because for that row the intCancellations column is probably NULL which will get upset if you try and format it into an number.
0
ramrodcarAuthor Commented:
no i added that for the distinction between a normal month row and the aggregate role, it's added to the label.
0
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

ramrodcarAuthor Commented:
it shouldn't be null, it happens if i hard code a number into the recordset, also i check for null here:
intCancellationUnitSum += IIf(System.Convert.IsDBNull(rowTemp.Item(7)), 0, rowTemp.Item(7)) '4/10
..
..
..
and add it here:
objNewRow(6) = IIf(System.Convert.IsDBNull(intCancellationUnitSum), 0, intCancellationUnitSum)
0
ramrodcarAuthor Commented:
but i have also tried taking away the format part of
Format(DataBinder.Eval(Container, "DataItem.intCancellations"),"###0."), and it doesn't fail
and i get nothing inbetween the <td> tags, so maybe it's null then.....
0
CBeach1980Commented:
Try stepping through the data in debug mode and make sure the value is a number.  It could be a blank string instead of null which would cause it to miss your IsDBNull check and yet still have a problem with formatting.
0
ramrodcarAuthor Commented:
here's the whole function:
    Private Function CreateAggregateByQuarter(ByRef ds As DataSet, ByVal strTableName As String) As String
        'Column 0 must be date type for this routine to work.

        Dim strAggTableName As String = strTableName + "_AggByQtr"

        ds.Tables.Add(New DataTable(strAggTableName))

        'Define the new table with the same dimensions as the base table.
        Dim clmTemp As DataColumn
        For Each clmTemp In ds.Tables(strTableName).Columns
                ds.Tables(strAggTableName).Columns.Add(New DataColumn(clmTemp.ColumnName, clmTemp.DataType))
                Label1.Text += clmTemp.ColumnName & " " & clmTemp.DataType.ToString & "<BR>"
            Next
            Label1.Text += "<BR>"

        'Add a new column to hold text description of the aggregate.
        ds.Tables(strAggTableName).Columns.Add(New DataColumn("txtAggDesc", System.Type.GetType("System.String")))
        Dim intAggLabelColumnIndex As Integer = ds.Tables(strAggTableName).Columns.Count - 1

        'Aggregate the values and place them into the new table.
        'This is where this function must be customized for the dataset.
        Dim rowTemp As DataRow
        Dim itmTemp As Object
            Dim intNetUnitsum As Integer = 0
            Dim intNetDollarsum As Integer = 0
            Dim intUCUnitSum As Integer = 0
            Dim intUSUnitSum As Integer = 0
            Dim intCancellationUnitSum As Integer = 0 '4/10

            Dim intUnitAllSum As Integer = 0
            Dim intDollarAllSum As Integer = 0
            Dim intUCUnitAllSum As Integer = 0
            Dim intUSUnitAllSum As Integer = 0
            Dim intCancellationUnitAllSum As Integer = 0 '4/10

            Dim objNewRow(intAggLabelColumnIndex) As Object

            'Sum all additive values and then add a new row when a quarter.
            Dim intRowCount As Integer = ds.Tables(strTableName).Rows.Count
            Dim intRow As Integer = 1
            Dim intStartMonth As Integer = 3
            Dim booAddRowFlag As Boolean = False

            For Each rowTemp In ds.Tables(strTableName).Rows
                'Item(0)is the date.
                intNetUnitsum += IIf(System.Convert.IsDBNull(rowTemp.Item(1)), 0, rowTemp.Item(1))
                intNetDollarsum += IIf(System.Convert.IsDBNull(rowTemp.Item(2)), 0, rowTemp.Item(2))
                intUCUnitSum += IIf(System.Convert.IsDBNull(rowTemp.Item(3)), 0, rowTemp.Item(3))
                intUSUnitSum += IIf(System.Convert.IsDBNull(rowTemp.Item(4)), 0, (rowTemp.Item(4)))

                intCancellationUnitSum += IIf(System.Convert.IsDBNull(rowTemp.Item(7)), 0, rowTemp.Item(7)) '4/10
                'intCancellationUnitSum = 234

                intUnitAllSum += IIf(System.Convert.IsDBNull(rowTemp.Item(1)), 0, rowTemp.Item(1))
                intDollarAllSum += IIf(System.Convert.IsDBNull(rowTemp.Item(2)), 0, rowTemp.Item(2))
                intUCUnitAllSum += IIf(System.Convert.IsDBNull(rowTemp.Item(3)), 0, rowTemp.Item(3))
                intUSUnitAllSum += IIf(System.Convert.IsDBNull(rowTemp.Item(4)), 0, (rowTemp.Item(4)))

                intCancellationUnitAllSum += IIf(System.Convert.IsDBNull(rowTemp.Item(7)), 0, rowTemp.Item(7)) '4/10

                Select Case (CDate(rowTemp.Item(0)).Month Mod 3)
                    Case 1  '1,4,7,10 ==> First month in a quarter
                        Select Case intRow
                            Case intRowCount 'It's the last row, so create the proper row label.
                                booAddRowFlag = True
                                objNewRow(intAggLabelColumnIndex) = CDate(rowTemp.Item(0)).ToShortDateString + " Only"
                            Case 1
                                intStartMonth = 1
                        End Select

                    Case 2  '2,5,8,11 ==> Second month in a quarter
                        Select Case intRow
                            Case intRowCount  'It's the last row, so create the proper row label.
                                booAddRowFlag = True
                                If intRowCount = 1 Then 'It's the first and last row
                                    objNewRow(intAggLabelColumnIndex) = CDate(rowTemp.Item(0)).ToShortDateString + " Only"
                                Else
                                    objNewRow(intAggLabelColumnIndex) = CDate(rowTemp.Item(0)).AddMonths(-1).ToShortDateString + " to " + CDate(rowTemp.Item(0)).ToShortDateString + " Only"
                                End If
                            Case 1
                                intStartMonth = 2
                        End Select

                    Case 0  '3,6,9,12 ==> Third month in a quarter
                        booAddRowFlag = True    'Add a new row regardless.
                        Select Case intStartMonth
                            Case 1  'Normal quarter with all three rows added.
                                objNewRow(intAggLabelColumnIndex) = CDate(rowTemp.Item(0)).Year.ToString + "Q" + Fix(CDate(rowTemp.Item(0)).Month / 3).ToString
                                'objnewrow(intAggLabelColumnIndex) = CDate(rowTemp.Item(0)).AddMonths(-2).ToShortDateString + " to " + CDate(rowTemp.Item(0)).ToShortDateString
                            Case 2  'The rows represent the last two months in the quarter
                                objNewRow(intAggLabelColumnIndex) = CDate(rowTemp.Item(0)).AddMonths(-1).ToShortDateString + " to " + CDate(rowTemp.Item(0)).ToShortDateString + " Only"
                            Case Else  'It's the first and last row
                                objNewRow(intAggLabelColumnIndex) = CDate(rowTemp.Item(0)).ToShortDateString + " Only"
                        End Select
                End Select

                If booAddRowFlag Then
                    booAddRowFlag = False ' Reset the flag

                    'Add the values to the table
                    objNewRow(0) = #1/1/1950# 'Cannot use DBNull.Value because it will generate an error.  But this should never be shown anyway.
                    objNewRow(1) = intNetUnitsum
                    objNewRow(2) = intNetDollarsum
                    objNewRow(3) = intUCUnitSum
                    objNewRow(4) = intUSUnitSum

                    objNewRow(5) = IIf(intUSUnitSum, intNetUnitsum / intUSUnitSum, 0)
                    objNewRow(6) = IIf(System.Convert.IsDBNull(intCancellationUnitSum), 0, intCancellationUnitSum) '4/10 'before lunch

                    ds.Tables(strAggTableName).Rows.Add(objNewRow)
                    Label1.Text += "<BR>"
                    Label1.Text += strTableName & " "
                    Dim k As Integer
                    For k = 0 To 6
                        Label1.Text += objNewRow(k).ToString & " "
                    Next k


                    'Zero the agg variables
                    intNetUnitsum = 0
                    intNetDollarsum = 0
                    intUCUnitSum = 0
                    intUSUnitSum = 0
                    intCancellationUnitSum = 0

                    'Reset the start month status each time you add a row to the table
                    intStartMonth = 1
                End If
                intRow += 1
            Next

            'Add the "all" values to the table
            objNewRow(0) = #1/1/1950# 'Cannot use DBNull.Value because it will generate an error.  But this should never be shown anyway.
            objNewRow(1) = intUnitAllSum
            objNewRow(2) = intDollarAllSum
            objNewRow(3) = intUCUnitAllSum
            objNewRow(4) = intUSUnitAllSum
            objNewRow(5) = IIf(intUSUnitAllSum, intUnitAllSum / intUSUnitAllSum, 0)
            objNewRow(6) = IIf(intCancellationUnitAllSum, intCancellationUnitAllSum, 0) '4/10

            Label1.Text += "<br/>========TOTALS: All Values================<BR>"
            Dim i As Integer

            For i = 0 To 6
                Label1.Text += objNewRow(i).ToString & " "
            Next i
            Label1.Text += "<BR><br>"

            objNewRow(intAggLabelColumnIndex) = "Period Sum"
            ds.Tables(strAggTableName).Rows.Add(objNewRow)
            Return strAggTableName
0
CBeach1980Commented:
Your data dump from the top doesn't have the same number of values as you have columns.  You only have 7 values and 9 columns so the intCancellations and intGrossUnits both appear to be null.
0
ramrodcarAuthor Commented:
the second table doesn't need 9 values, it only needs the 7, this second table doesn't use all the values from the other datalists dataset.
0
CBeach1980Commented:
That's fine but assigning the values by index causes the last 2 columns to be empty which happens to include the intCancellations column.  You'd need to either assign to all the indicies, assign the values by column name, or remove the unnecessary columns from the table so that you are assigning to each index.

---------------------
'Add the values to the table
objNewRow(0) = #1/1/1950# 'Cannot use DBNull.Value because it will generate an error.  But this should never be shown anyway.
objNewRow(1) = intNetUnitsum
objNewRow(2) = intNetDollarsum
objNewRow(3) = intUCUnitSum
objNewRow(4) = intUSUnitSum
objNewRow(5) = IIf(intUSUnitSum, intNetUnitsum / intUSUnitSum, 0)
objNewRow(6) = IIf(System.Convert.IsDBNull(intCancellationUnitSum), 0,intCancellationUnitSum) '4/10 'before lunch
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ramrodcarAuthor Commented:
Thank you very much sir, hit the nail right on the head.
0
CBeach1980Commented:
My pleasure.  Glad to be of help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.