String was not recognized as a valid Boolean


G

Guest

Why am I getting this error for Budget?

Error: An exception of type 'System.FormatException' occurred in
mscorlib.dll but was not handled in user code

Additional information: String was not recognized as a valid Boolean.


Public Sub UpdateCustomer_DashboardGraphs(ByVal sender As Object, ByVal
e As System.EventArgs)
For Each gvr As GridViewRow In gv_dashboard.Rows
If gvr.RowType = DataControlRowType.DataRow Then

'//--IDs

Dim intCustomerID As String =
CType(gvr.FindControl("lblCustomerID"), Label).Text.Trim()

'//--Textboxes
Dim intBudget As Integer
Try
intBudget = CType(CType(gvr.FindControl("txtBudget"),
TextBox).Text.Trim(), Int32)
Catch
intBudget = CType(0, Int32)
End Try

'//--Checkboxes
Dim intCurrentMonthCollections As Boolean =
CType(gvr.FindControl("chbx_CurrentMonthCollections"), CheckBox).Checked
Dim intRevenueByMonth As Boolean =
CType(gvr.FindControl("chbx_RevenueByMonth"), CheckBox).Checked
Dim intPDCsCCsMonthly As Boolean =
CType(gvr.FindControl("chbx_PDCsCCsMonthly"), CheckBox).Checked
Dim intRevenueByClient As Boolean =
CType(gvr.FindControl("chbx_RevenueByClient"), CheckBox).Checked

'//--Assign UpdateParameters
If intCurrentMonthCollections = True Then

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 1
Else

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 0
End If
....

ds_dashboard.UpdateParameters("Budget").DefaultValue =
intBudget

ds_dashboard.Update()
End If
Next
End Sub
 
Ad

Advertisements

G

Guest

String was not recognized as a valid Boolean

For Line: ds_dashboard.Update() in my update function


My SQLDataSource:
-------------------------

<asp:SqlDataSource
ID="ds_dashboard"
runat="server"
ConnectionString="<%$ ConnectionStrings:DashboardConn %>"
SelectCommand="aspx_Get_Customer_DashboardGraphs"
SelectCommandType="StoredProcedure"
UpdateCommand="aspx_Update_Customer_DashboardGraphs"
UpdateCommandType="StoredProcedure"<UpdateParameters>
<asp:parameter Name="CustomerID" Type="Int32" />
<asp:parameter Name="Budget" Type="Int32" />
<asp:parameter Name="CurrentMonthCollections"
Type="Boolean" />
<asp:parameter Name="RevenueByMonth" Type="Boolean" />
<asp:parameter Name="PDCsCCsMonthly" Type="Boolean" />
<asp:parameter Name="RevenueByClient" Type="Boolean" />

</UpdateParameters>

</asp:SqlDataSource>


My GridView:
---------------------

<asp:GridView
ID="gv_dashboard"
runat="server"
AutoGenerateColumns="False"
DataSourceID="ds_dashboard"
CellPadding="4"
ForeColor="#333333"
ShowFooter="True"
GridLines="None"
CssClass="FormatFont">

<Columns>
<asp:TemplateField HeaderText="Cust #"
SortExpression="CustomerID">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:Label runat="server" id="lblCustomerID"
Text='<%# Bind("Customer") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Budget" SortExpression="Name"
ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
<ItemTemplate>
<asp:TextBox width="55px" MaxLength="10"
ID="txtBudget" Text='<%# Bind("Budget") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Current Month Collections"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_CurrentMonthCollections" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Revenue By Month"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_RevenueByMonth" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="PDCs & CCS Monthly"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_PDCsCCsMonthly" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Revenue By Client"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_RevenueByClient" />
</ItemTemplate>
</asp:TemplateField>
</Columns>

<FooterStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#DDDDDD" />
<SelectedRowStyle BackColor="#DDDDDD" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>


My Update Command (Stored Procedure):
--------------------------------------------------

ALTER PROCEDURE [dbo].[aspx_Update_Customer_DashboardGraphs]

@CustomerID bigint,
@Budget int,
@CurrentMonthCollections bit,
@RevenueByMonth bit,
@PDCsCCsMonthly bit,
@RevenueByClient bit

AS
BEGIN

UPDATE dbo.Customer_DashboardGraphs
SET Budget = @Budget,
CurrentMonthCollections = @CurrentMonthCollections,
RevenueByMonth = @RevenueByMonth,
PDCsCCsMonthly = @PDCsCCsMonthly,
RevenueByClient = @RevenueByClient
WHERE Customer_DashboardGraphs.Customer = @CustomerID
END


My Table Schema:
-----------------------

CREATE TABLE [dbo].[Customer_DashboardGraphs](
[Customer] [nchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DashboardGraphID] [bit] NULL,
[CurrentMonthCollections] [bit] NULL,
[RevenueByMonth] [bit] NULL,
[PDCsCCsMonthly] [bit] NULL,
[RevenueByClient] [bit] NULL,
[Budget] [int] NULL
) ON [PRIMARY]
Stack Trace:

String was not recognized as a valid Boolean.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.FormatException: String was not recognized as a
valid Boolean.

Source Error:


Line 53:
ds_dashboard.UpdateParameters("Budget").DefaultValue = intBudget
Line 54:
Line 55: ds_dashboard.Update()
Line 56: End If
Line 57: Next


Source File:
Y:\inetpub\wwwroot\apex\webapps\dashboard\dashboard\index.aspx.vb Line: 55


Stack Trace:
------------------

[FormatException: String was not recognized as a valid Boolean.]
System.Boolean.Parse(String value) +2709172
System.String.System.IConvertible.ToBoolean(IFormatProvider provider) +12
System.Convert.ChangeType(Object value, TypeCode typeCode,
IFormatProvider provider) +98
System.Web.UI.WebControls.Parameter.GetValue(Object value, String
defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean
ignoreNullableTypeChanges) +257
System.Web.UI.WebControls.Parameter.get_ParameterValue() +91
System.Web.UI.WebControls.ParameterCollection.GetValues(HttpContext
context, Control control) +282

System.Web.UI.WebControls.SqlDataSourceView.InitializeParameters(DbCommand
command, ParameterCollection parameters, IDictionary exclusionList) +344
System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary
keys, IDictionary values, IDictionary oldValues) +449
System.Web.UI.WebControls.SqlDataSourceView.Update(IDictionary keys,
IDictionary values, IDictionary oldValues) +37
System.Web.UI.WebControls.SqlDataSource.Update() +42
dashboard._Default.UpdateCustomer_DashboardGraphs(Object sender,
EventArgs e) in
Y:\inetpub\wwwroot\sss\webapps\dashboard\dashboard\index.aspx.vb:55
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +96
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
+116

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +72
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3837
 
G

Guest

Ok, I changed these since SQL Server bit is expecting true or false, not 1 or
zero...that would be for an integer db field:

If intCurrentMonthCollections = True Then

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 1
Else

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 0
End If

to

If intCurrentMonthCollections = True Then

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = "true"
Else

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue =
"false"
End If

The error goes away but it's still not updating those bit fields in my table


--
dba123


dba123 said:
String was not recognized as a valid Boolean

For Line: ds_dashboard.Update() in my update function


My SQLDataSource:
-------------------------

<asp:SqlDataSource
ID="ds_dashboard"
runat="server"
ConnectionString="<%$ ConnectionStrings:DashboardConn %>"
SelectCommand="aspx_Get_Customer_DashboardGraphs"
SelectCommandType="StoredProcedure"
UpdateCommand="aspx_Update_Customer_DashboardGraphs"
UpdateCommandType="StoredProcedure"<UpdateParameters>
<asp:parameter Name="CustomerID" Type="Int32" />
<asp:parameter Name="Budget" Type="Int32" />
<asp:parameter Name="CurrentMonthCollections"
Type="Boolean" />
<asp:parameter Name="RevenueByMonth" Type="Boolean" />
<asp:parameter Name="PDCsCCsMonthly" Type="Boolean" />
<asp:parameter Name="RevenueByClient" Type="Boolean" />

</UpdateParameters>

</asp:SqlDataSource>


My GridView:
---------------------

<asp:GridView
ID="gv_dashboard"
runat="server"
AutoGenerateColumns="False"
DataSourceID="ds_dashboard"
CellPadding="4"
ForeColor="#333333"
ShowFooter="True"
GridLines="None"
CssClass="FormatFont">

<Columns>
<asp:TemplateField HeaderText="Cust #"
SortExpression="CustomerID">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:Label runat="server" id="lblCustomerID"
Text='<%# Bind("Customer") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Budget" SortExpression="Name"
ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
<ItemTemplate>
<asp:TextBox width="55px" MaxLength="10"
ID="txtBudget" Text='<%# Bind("Budget") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Current Month Collections"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_CurrentMonthCollections" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Revenue By Month"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_RevenueByMonth" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="PDCs & CCS Monthly"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_PDCsCCsMonthly" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Revenue By Client"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_RevenueByClient" />
</ItemTemplate>
</asp:TemplateField>
</Columns>

<FooterStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#DDDDDD" />
<SelectedRowStyle BackColor="#DDDDDD" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>


My Update Command (Stored Procedure):
--------------------------------------------------

ALTER PROCEDURE [dbo].[aspx_Update_Customer_DashboardGraphs]

@CustomerID bigint,
@Budget int,
@CurrentMonthCollections bit,
@RevenueByMonth bit,
@PDCsCCsMonthly bit,
@RevenueByClient bit

AS
BEGIN

UPDATE dbo.Customer_DashboardGraphs
SET Budget = @Budget,
CurrentMonthCollections = @CurrentMonthCollections,
RevenueByMonth = @RevenueByMonth,
PDCsCCsMonthly = @PDCsCCsMonthly,
RevenueByClient = @RevenueByClient
WHERE Customer_DashboardGraphs.Customer = @CustomerID
END


My Table Schema:
-----------------------

CREATE TABLE [dbo].[Customer_DashboardGraphs](
[Customer] [nchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DashboardGraphID] [bit] NULL,
[CurrentMonthCollections] [bit] NULL,
[RevenueByMonth] [bit] NULL,
[PDCsCCsMonthly] [bit] NULL,
[RevenueByClient] [bit] NULL,
[Budget] [int] NULL
) ON [PRIMARY]
Stack Trace:

String was not recognized as a valid Boolean.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.FormatException: String was not recognized as a
valid Boolean.

Source Error:


Line 53:
ds_dashboard.UpdateParameters("Budget").DefaultValue = intBudget
Line 54:
Line 55: ds_dashboard.Update()
Line 56: End If
Line 57: Next


Source File:
Y:\inetpub\wwwroot\apex\webapps\dashboard\dashboard\index.aspx.vb Line: 55


Stack Trace:
------------------

[FormatException: String was not recognized as a valid Boolean.]
System.Boolean.Parse(String value) +2709172
System.String.System.IConvertible.ToBoolean(IFormatProvider provider) +12
System.Convert.ChangeType(Object value, TypeCode typeCode,
IFormatProvider provider) +98
System.Web.UI.WebControls.Parameter.GetValue(Object value, String
defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean
ignoreNullableTypeChanges) +257
System.Web.UI.WebControls.Parameter.get_ParameterValue() +91
System.Web.UI.WebControls.ParameterCollection.GetValues(HttpContext
context, Control control) +282

System.Web.UI.WebControls.SqlDataSourceView.InitializeParameters(DbCommand
command, ParameterCollection parameters, IDictionary exclusionList) +344
System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary
keys, IDictionary values, IDictionary oldValues) +449
System.Web.UI.WebControls.SqlDataSourceView.Update(IDictionary keys,
IDictionary values, IDictionary oldValues) +37
System.Web.UI.WebControls.SqlDataSource.Update() +42
dashboard._Default.UpdateCustomer_DashboardGraphs(Object sender,
EventArgs e) in
Y:\inetpub\wwwroot\sss\webapps\dashboard\dashboard\index.aspx.vb:55
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +96
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
+116

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +72
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3837


--
dba123


Karl Seguin said:
which line is the error on?

Karl
 
K

Karl Seguin [MVP]

Why don't you just set it to true/false instead of "true"/"fale"

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue =
intCurrentMonthCollections

and why is that var prefixed with "int" if it's a bool? Prefixing isn't
really used much anymore anyways..

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


dba123 said:
Ok, I changed these since SQL Server bit is expecting true or false, not 1
or
zero...that would be for an integer db field:

If intCurrentMonthCollections = True Then

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 1
Else

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 0
End If

to

If intCurrentMonthCollections = True Then

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue =
"true"
Else

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue =
"false"
End If

The error goes away but it's still not updating those bit fields in my
table


--
dba123


dba123 said:
String was not recognized as a valid Boolean

For Line: ds_dashboard.Update() in my update function


My SQLDataSource:
-------------------------

<asp:SqlDataSource
ID="ds_dashboard"
runat="server"
ConnectionString="<%$ ConnectionStrings:DashboardConn %>"
SelectCommand="aspx_Get_Customer_DashboardGraphs"
SelectCommandType="StoredProcedure"
UpdateCommand="aspx_Update_Customer_DashboardGraphs"
UpdateCommandType="StoredProcedure"<UpdateParameters>
<asp:parameter Name="CustomerID" Type="Int32" />
<asp:parameter Name="Budget" Type="Int32" />
<asp:parameter Name="CurrentMonthCollections"
Type="Boolean" />
<asp:parameter Name="RevenueByMonth" Type="Boolean"
/>
<asp:parameter Name="PDCsCCsMonthly" Type="Boolean"
/>
<asp:parameter Name="RevenueByClient" Type="Boolean"
/>

</UpdateParameters>

</asp:SqlDataSource>


My GridView:
---------------------

<asp:GridView
ID="gv_dashboard"
runat="server"
AutoGenerateColumns="False"
DataSourceID="ds_dashboard"
CellPadding="4"
ForeColor="#333333"
ShowFooter="True"
GridLines="None"
CssClass="FormatFont">

<Columns>
<asp:TemplateField HeaderText="Cust #"
SortExpression="CustomerID">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:Label runat="server" id="lblCustomerID"
Text='<%# Bind("Customer") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Budget"
SortExpression="Name"
ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
<ItemTemplate>
<asp:TextBox width="55px" MaxLength="10"
ID="txtBudget" Text='<%# Bind("Budget") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Current Month Collections"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_CurrentMonthCollections" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Revenue By Month"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_RevenueByMonth" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="PDCs & CCS Monthly"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_PDCsCCsMonthly" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Revenue By Client"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_RevenueByClient" />
</ItemTemplate>
</asp:TemplateField>
</Columns>

<FooterStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#DDDDDD" />
<SelectedRowStyle BackColor="#DDDDDD" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>


My Update Command (Stored Procedure):
--------------------------------------------------

ALTER PROCEDURE [dbo].[aspx_Update_Customer_DashboardGraphs]

@CustomerID bigint,
@Budget int,
@CurrentMonthCollections bit,
@RevenueByMonth bit,
@PDCsCCsMonthly bit,
@RevenueByClient bit

AS
BEGIN

UPDATE dbo.Customer_DashboardGraphs
SET Budget = @Budget,
CurrentMonthCollections = @CurrentMonthCollections,
RevenueByMonth = @RevenueByMonth,
PDCsCCsMonthly = @PDCsCCsMonthly,
RevenueByClient = @RevenueByClient
WHERE Customer_DashboardGraphs.Customer = @CustomerID
END


My Table Schema:
-----------------------

CREATE TABLE [dbo].[Customer_DashboardGraphs](
[Customer] [nchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DashboardGraphID] [bit] NULL,
[CurrentMonthCollections] [bit] NULL,
[RevenueByMonth] [bit] NULL,
[PDCsCCsMonthly] [bit] NULL,
[RevenueByClient] [bit] NULL,
[Budget] [int] NULL
) ON [PRIMARY]
Stack Trace:

String was not recognized as a valid Boolean.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about
the error and where it originated in the code.

Exception Details: System.FormatException: String was not recognized as a
valid Boolean.

Source Error:


Line 53:
ds_dashboard.UpdateParameters("Budget").DefaultValue = intBudget
Line 54:
Line 55: ds_dashboard.Update()
Line 56: End If
Line 57: Next


Source File:
Y:\inetpub\wwwroot\apex\webapps\dashboard\dashboard\index.aspx.vb
Line: 55


Stack Trace:
------------------

[FormatException: String was not recognized as a valid Boolean.]
System.Boolean.Parse(String value) +2709172
System.String.System.IConvertible.ToBoolean(IFormatProvider provider)
+12
System.Convert.ChangeType(Object value, TypeCode typeCode,
IFormatProvider provider) +98
System.Web.UI.WebControls.Parameter.GetValue(Object value, String
defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean
ignoreNullableTypeChanges) +257
System.Web.UI.WebControls.Parameter.get_ParameterValue() +91
System.Web.UI.WebControls.ParameterCollection.GetValues(HttpContext
context, Control control) +282

System.Web.UI.WebControls.SqlDataSourceView.InitializeParameters(DbCommand
command, ParameterCollection parameters, IDictionary exclusionList) +344
System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary
keys, IDictionary values, IDictionary oldValues) +449
System.Web.UI.WebControls.SqlDataSourceView.Update(IDictionary keys,
IDictionary values, IDictionary oldValues) +37
System.Web.UI.WebControls.SqlDataSource.Update() +42
dashboard._Default.UpdateCustomer_DashboardGraphs(Object sender,
EventArgs e) in
Y:\inetpub\wwwroot\sss\webapps\dashboard\dashboard\index.aspx.vb:55
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +96
System.Web.UI.WebControls.Button.RaisePostBackEvent(String
eventArgument)
+116

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+72
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+3837


--
dba123


Karl Seguin said:
which line is the error on?

Karl

--
http://www.openmymind.net/



Why am I getting this error for Budget?

Error: An exception of type 'System.FormatException' occurred in
mscorlib.dll but was not handled in user code

Additional information: String was not recognized as a valid Boolean.


Public Sub UpdateCustomer_DashboardGraphs(ByVal sender As Object,
ByVal
e As System.EventArgs)
For Each gvr As GridViewRow In gv_dashboard.Rows
If gvr.RowType = DataControlRowType.DataRow Then

'//--IDs

Dim intCustomerID As String =
CType(gvr.FindControl("lblCustomerID"), Label).Text.Trim()

'//--Textboxes
Dim intBudget As Integer
Try
intBudget =
CType(CType(gvr.FindControl("txtBudget"),
TextBox).Text.Trim(), Int32)
Catch
intBudget = CType(0, Int32)
End Try

'//--Checkboxes
Dim intCurrentMonthCollections As Boolean =
CType(gvr.FindControl("chbx_CurrentMonthCollections"),
CheckBox).Checked
Dim intRevenueByMonth As Boolean =
CType(gvr.FindControl("chbx_RevenueByMonth"), CheckBox).Checked
Dim intPDCsCCsMonthly As Boolean =
CType(gvr.FindControl("chbx_PDCsCCsMonthly"), CheckBox).Checked
Dim intRevenueByClient As Boolean =
CType(gvr.FindControl("chbx_RevenueByClient"), CheckBox).Checked

'//--Assign UpdateParameters
If intCurrentMonthCollections = True Then

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue
= 1
Else

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue
= 0
End If
...

ds_dashboard.UpdateParameters("Budget").DefaultValue =
intBudget

ds_dashboard.Update()
End If
Next
End Sub
 
G

Guest

Looks like I was missing the checked attribute in my GridView checkboxes??

I changed them to this for example but got an error

<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_CurrentMonthCollections" Checked='<%#
Bind("CurrentMonthCollections") %>'/>
</ItemTemplate>
</asp:TemplateField>

Error: An exception of type 'System.InvalidCastException' occurred in
Microsoft.VisualBasic.dll but was not handled in user code

Additional information: Conversion from type 'DBNull' to type 'Boolean' is
not valid.
 
Ad

Advertisements

G

Guest

I still think prefix is useful for readablility.

Anyway, I trued True and False instead of "True" and "False" it made no
diffrence. Check out my previous post.

--
dba123


Karl Seguin said:
Why don't you just set it to true/false instead of "true"/"fale"

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue =
intCurrentMonthCollections

and why is that var prefixed with "int" if it's a bool? Prefixing isn't
really used much anymore anyways..

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


dba123 said:
Ok, I changed these since SQL Server bit is expecting true or false, not 1
or
zero...that would be for an integer db field:

If intCurrentMonthCollections = True Then

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 1
Else

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 0
End If

to

If intCurrentMonthCollections = True Then

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue =
"true"
Else

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue =
"false"
End If

The error goes away but it's still not updating those bit fields in my
table


--
dba123


dba123 said:
String was not recognized as a valid Boolean

For Line: ds_dashboard.Update() in my update function


My SQLDataSource:
-------------------------

<asp:SqlDataSource
ID="ds_dashboard"
runat="server"
ConnectionString="<%$ ConnectionStrings:DashboardConn %>"
SelectCommand="aspx_Get_Customer_DashboardGraphs"
SelectCommandType="StoredProcedure"
UpdateCommand="aspx_Update_Customer_DashboardGraphs"
UpdateCommandType="StoredProcedure"

<UpdateParameters>
<asp:parameter Name="CustomerID" Type="Int32" />
<asp:parameter Name="Budget" Type="Int32" />
<asp:parameter Name="CurrentMonthCollections"
Type="Boolean" />
<asp:parameter Name="RevenueByMonth" Type="Boolean"
/>
<asp:parameter Name="PDCsCCsMonthly" Type="Boolean"
/>
<asp:parameter Name="RevenueByClient" Type="Boolean"
/>

</UpdateParameters>

</asp:SqlDataSource>


My GridView:
---------------------

<asp:GridView
ID="gv_dashboard"
runat="server"
AutoGenerateColumns="False"
DataSourceID="ds_dashboard"
CellPadding="4"
ForeColor="#333333"
ShowFooter="True"
GridLines="None"
CssClass="FormatFont">

<Columns>
<asp:TemplateField HeaderText="Cust #"
SortExpression="CustomerID">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:Label runat="server" id="lblCustomerID"
Text='<%# Bind("Customer") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Budget"
SortExpression="Name"
ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
<ItemTemplate>
<asp:TextBox width="55px" MaxLength="10"
ID="txtBudget" Text='<%# Bind("Budget") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Current Month Collections"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_CurrentMonthCollections" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Revenue By Month"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_RevenueByMonth" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="PDCs & CCS Monthly"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_PDCsCCsMonthly" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Revenue By Client"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_RevenueByClient" />
</ItemTemplate>
</asp:TemplateField>
</Columns>

<FooterStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#DDDDDD" />
<SelectedRowStyle BackColor="#DDDDDD" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>


My Update Command (Stored Procedure):
--------------------------------------------------

ALTER PROCEDURE [dbo].[aspx_Update_Customer_DashboardGraphs]

@CustomerID bigint,
@Budget int,
@CurrentMonthCollections bit,
@RevenueByMonth bit,
@PDCsCCsMonthly bit,
@RevenueByClient bit

AS
BEGIN

UPDATE dbo.Customer_DashboardGraphs
SET Budget = @Budget,
CurrentMonthCollections = @CurrentMonthCollections,
RevenueByMonth = @RevenueByMonth,
PDCsCCsMonthly = @PDCsCCsMonthly,
RevenueByClient = @RevenueByClient
WHERE Customer_DashboardGraphs.Customer = @CustomerID
END


My Table Schema:
-----------------------

CREATE TABLE [dbo].[Customer_DashboardGraphs](
[Customer] [nchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DashboardGraphID] [bit] NULL,
[CurrentMonthCollections] [bit] NULL,
[RevenueByMonth] [bit] NULL,
[PDCsCCsMonthly] [bit] NULL,
[RevenueByClient] [bit] NULL,
[Budget] [int] NULL
) ON [PRIMARY]
Stack Trace:

String was not recognized as a valid Boolean.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about
the error and where it originated in the code.

Exception Details: System.FormatException: String was not recognized as a
valid Boolean.

Source Error:


Line 53:
ds_dashboard.UpdateParameters("Budget").DefaultValue = intBudget
Line 54:
Line 55: ds_dashboard.Update()
Line 56: End If
Line 57: Next


Source File:
Y:\inetpub\wwwroot\apex\webapps\dashboard\dashboard\index.aspx.vb
Line: 55


Stack Trace:
------------------

[FormatException: String was not recognized as a valid Boolean.]
System.Boolean.Parse(String value) +2709172
System.String.System.IConvertible.ToBoolean(IFormatProvider provider)
+12
System.Convert.ChangeType(Object value, TypeCode typeCode,
IFormatProvider provider) +98
System.Web.UI.WebControls.Parameter.GetValue(Object value, String
defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean
ignoreNullableTypeChanges) +257
System.Web.UI.WebControls.Parameter.get_ParameterValue() +91
System.Web.UI.WebControls.ParameterCollection.GetValues(HttpContext
context, Control control) +282

System.Web.UI.WebControls.SqlDataSourceView.InitializeParameters(DbCommand
command, ParameterCollection parameters, IDictionary exclusionList) +344
System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary
keys, IDictionary values, IDictionary oldValues) +449
System.Web.UI.WebControls.SqlDataSourceView.Update(IDictionary keys,
IDictionary values, IDictionary oldValues) +37
System.Web.UI.WebControls.SqlDataSource.Update() +42
dashboard._Default.UpdateCustomer_DashboardGraphs(Object sender,
EventArgs e) in
Y:\inetpub\wwwroot\sss\webapps\dashboard\dashboard\index.aspx.vb:55
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +96
System.Web.UI.WebControls.Button.RaisePostBackEvent(String
eventArgument)
+116

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+72
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+3837


--
dba123


:

which line is the error on?

Karl

--
http://www.openmymind.net/



Why am I getting this error for Budget?

Error: An exception of type 'System.FormatException' occurred in
mscorlib.dll but was not handled in user code

Additional information: String was not recognized as a valid Boolean.


Public Sub UpdateCustomer_DashboardGraphs(ByVal sender As Object,
ByVal
e As System.EventArgs)
For Each gvr As GridViewRow In gv_dashboard.Rows
 
G

Guest

The answer to your question is..because I haven't cleaned up my code, I'll do
that at the end and change the prefixes, right now I just want to get this
thing to work!

--
dba123


Karl Seguin said:
Why don't you just set it to true/false instead of "true"/"fale"

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue =
intCurrentMonthCollections

and why is that var prefixed with "int" if it's a bool? Prefixing isn't
really used much anymore anyways..

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


dba123 said:
Ok, I changed these since SQL Server bit is expecting true or false, not 1
or
zero...that would be for an integer db field:

If intCurrentMonthCollections = True Then

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 1
Else

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 0
End If

to

If intCurrentMonthCollections = True Then

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue =
"true"
Else

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue =
"false"
End If

The error goes away but it's still not updating those bit fields in my
table


--
dba123


dba123 said:
String was not recognized as a valid Boolean

For Line: ds_dashboard.Update() in my update function


My SQLDataSource:
-------------------------

<asp:SqlDataSource
ID="ds_dashboard"
runat="server"
ConnectionString="<%$ ConnectionStrings:DashboardConn %>"
SelectCommand="aspx_Get_Customer_DashboardGraphs"
SelectCommandType="StoredProcedure"
UpdateCommand="aspx_Update_Customer_DashboardGraphs"
UpdateCommandType="StoredProcedure"

<UpdateParameters>
<asp:parameter Name="CustomerID" Type="Int32" />
<asp:parameter Name="Budget" Type="Int32" />
<asp:parameter Name="CurrentMonthCollections"
Type="Boolean" />
<asp:parameter Name="RevenueByMonth" Type="Boolean"
/>
<asp:parameter Name="PDCsCCsMonthly" Type="Boolean"
/>
<asp:parameter Name="RevenueByClient" Type="Boolean"
/>

</UpdateParameters>

</asp:SqlDataSource>


My GridView:
---------------------

<asp:GridView
ID="gv_dashboard"
runat="server"
AutoGenerateColumns="False"
DataSourceID="ds_dashboard"
CellPadding="4"
ForeColor="#333333"
ShowFooter="True"
GridLines="None"
CssClass="FormatFont">

<Columns>
<asp:TemplateField HeaderText="Cust #"
SortExpression="CustomerID">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:Label runat="server" id="lblCustomerID"
Text='<%# Bind("Customer") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Budget"
SortExpression="Name"
ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
<ItemTemplate>
<asp:TextBox width="55px" MaxLength="10"
ID="txtBudget" Text='<%# Bind("Budget") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Current Month Collections"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_CurrentMonthCollections" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Revenue By Month"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_RevenueByMonth" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="PDCs & CCS Monthly"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_PDCsCCsMonthly" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Revenue By Client"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_RevenueByClient" />
</ItemTemplate>
</asp:TemplateField>
</Columns>

<FooterStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#DDDDDD" />
<SelectedRowStyle BackColor="#DDDDDD" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>


My Update Command (Stored Procedure):
--------------------------------------------------

ALTER PROCEDURE [dbo].[aspx_Update_Customer_DashboardGraphs]

@CustomerID bigint,
@Budget int,
@CurrentMonthCollections bit,
@RevenueByMonth bit,
@PDCsCCsMonthly bit,
@RevenueByClient bit

AS
BEGIN

UPDATE dbo.Customer_DashboardGraphs
SET Budget = @Budget,
CurrentMonthCollections = @CurrentMonthCollections,
RevenueByMonth = @RevenueByMonth,
PDCsCCsMonthly = @PDCsCCsMonthly,
RevenueByClient = @RevenueByClient
WHERE Customer_DashboardGraphs.Customer = @CustomerID
END


My Table Schema:
-----------------------

CREATE TABLE [dbo].[Customer_DashboardGraphs](
[Customer] [nchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DashboardGraphID] [bit] NULL,
[CurrentMonthCollections] [bit] NULL,
[RevenueByMonth] [bit] NULL,
[PDCsCCsMonthly] [bit] NULL,
[RevenueByClient] [bit] NULL,
[Budget] [int] NULL
) ON [PRIMARY]
Stack Trace:

String was not recognized as a valid Boolean.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about
the error and where it originated in the code.

Exception Details: System.FormatException: String was not recognized as a
valid Boolean.

Source Error:


Line 53:
ds_dashboard.UpdateParameters("Budget").DefaultValue = intBudget
Line 54:
Line 55: ds_dashboard.Update()
Line 56: End If
Line 57: Next


Source File:
Y:\inetpub\wwwroot\apex\webapps\dashboard\dashboard\index.aspx.vb
Line: 55


Stack Trace:
------------------

[FormatException: String was not recognized as a valid Boolean.]
System.Boolean.Parse(String value) +2709172
System.String.System.IConvertible.ToBoolean(IFormatProvider provider)
+12
System.Convert.ChangeType(Object value, TypeCode typeCode,
IFormatProvider provider) +98
System.Web.UI.WebControls.Parameter.GetValue(Object value, String
defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean
ignoreNullableTypeChanges) +257
System.Web.UI.WebControls.Parameter.get_ParameterValue() +91
System.Web.UI.WebControls.ParameterCollection.GetValues(HttpContext
context, Control control) +282

System.Web.UI.WebControls.SqlDataSourceView.InitializeParameters(DbCommand
command, ParameterCollection parameters, IDictionary exclusionList) +344
System.Web.UI.WebControls.SqlDataSourceView.ExecuteUpdate(IDictionary
keys, IDictionary values, IDictionary oldValues) +449
System.Web.UI.WebControls.SqlDataSourceView.Update(IDictionary keys,
IDictionary values, IDictionary oldValues) +37
System.Web.UI.WebControls.SqlDataSource.Update() +42
dashboard._Default.UpdateCustomer_DashboardGraphs(Object sender,
EventArgs e) in
Y:\inetpub\wwwroot\sss\webapps\dashboard\dashboard\index.aspx.vb:55
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +96
System.Web.UI.WebControls.Button.RaisePostBackEvent(String
eventArgument)
+116

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+72
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+3837


--
dba123


:

which line is the error on?

Karl

--
http://www.openmymind.net/



Why am I getting this error for Budget?

Error: An exception of type 'System.FormatException' occurred in
mscorlib.dll but was not handled in user code

Additional information: String was not recognized as a valid Boolean.


Public Sub UpdateCustomer_DashboardGraphs(ByVal sender As Object,
ByVal
e As System.EventArgs)
For Each gvr As GridViewRow In gv_dashboard.Rows
 
K

Karl Seguin [MVP]

you need to check for null. Either don't allow null in that column and use
a default value, use select IsNull(CurrentMonthCollections, false) as
CurrentMonthCollections for selecting a default value, or check for null
before binding, you can do that inline via:

<%# ( Bind("CurrentMonthCollections") == DBNull.Value) ? false : true; %>

Karl
 
G

Guest

Thanks you are correct. What I did was changed my SelectCommand stored proc
to replace the nulls with 0 instead.

see here for my latest code. Now no errors but also no updates happening on
the DB side:


Here's a recap of the code I have now...trying to figure out why with no
errors, is it still not updating my table with the results:



<asp:SqlDataSource
ID="ds_dashboard"
runat="server"
ConnectionString="<%$ ConnectionStrings:DashboardConn %>"
SelectCommand="aspx_Get_Customer_DashboardGraphs"
SelectCommandType="StoredProcedure"
UpdateCommand="aspx_Update_Customer_DashboardGraphs"
UpdateCommandType="StoredProcedure"<UpdateParameters>
<asp:parameter Name="CustomerID" Type="Int32" />
<asp:parameter Name="Budget" Type="Int32" />
<asp:parameter Name="CurrentMonthCollections"
Type="Boolean" />
<asp:parameter Name="RevenueByMonth" Type="Boolean" />
<asp:parameter Name="PDCsCCsMonthly" Type="Boolean" />
<asp:parameter Name="RevenueByClient" Type="Boolean" />

</UpdateParameters>

</asp:SqlDataSource>


<asp:GridView
ID="gv_dashboard"
runat="server"
AutoGenerateColumns="False"
DataSourceID="ds_dashboard"
CellPadding="4"
ForeColor="#333333"
ShowFooter="True"
GridLines="None"
CssClass="FormatFont">

<Columns>
<asp:TemplateField HeaderText="Cust #"
SortExpression="CustomerID">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:Label runat="server" id="lblCustomerID"
Text='<%# Bind("Customer") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Budget" SortExpression="Name"
ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
<ItemTemplate>
<asp:TextBox width="55px" MaxLength="10"
ID="txtBudget" Text='<%# Bind("Budget") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Current Month Collections"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_CurrentMonthCollections" Checked='<%#
Bind("CurrentMonthCollections") %>'/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Revenue By Month"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_RevenueByMonth" Checked='<%# Bind("RevenueByMonth") %>'/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="PDCs & CCS Monthly"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_PDCsCCsMonthly" Checked='<%# Bind("PDCsCCsMonthly") %>'/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Revenue By Client"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_RevenueByClient" Checked='<%# Bind("RevenueByClient") %>'/>
</ItemTemplate>
</asp:TemplateField>
</Columns>

<FooterStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#DDDDDD" />
<SelectedRowStyle BackColor="#DDDDDD" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />

</asp:GridView>


Stored proc behind the Select Command

ALTER PROCEDURE [dbo].[aspx_Get_Customer_DashboardGraphs]

AS
BEGIN

SELECT Customer,
ISNULL(Budget, 0) as Budget,
ISNULL(CurrentMonthCollections, 0) as CurrentMonthCollections,
ISNULL(RevenueByMonth, 0)as RevenueByMonth,
ISNULL(PDCsCCsMonthly, 0) as PDCsCCsMonthly,
ISNULL(RevenueByClient, 0) as RevenueByClient


FROM v_Get_Customer_DashboardGraphs_Data
ORDER BY Customer ASC
END


Stored proc behind the Update Command:

ALTER PROCEDURE [dbo].[aspx_Update_Customer_DashboardGraphs]

@CustomerID bigint,
@Budget bigint,
@CurrentMonthCollections bit,
@RevenueByMonth bit,
@PDCsCCsMonthly bit,
@RevenueByClient bit

AS
BEGIN

UPDATE dbo.Customer_DashboardGraphs
SET Budget = @Budget,
CurrentMonthCollections = @CurrentMonthCollections,
RevenueByMonth = @RevenueByMonth,
PDCsCCsMonthly = @PDCsCCsMonthly,
RevenueByClient = @RevenueByClient
WHERE Customer_DashboardGraphs.Customer = @CustomerID
END


------------------------------------- Code Behind
-------------------------------------------------------------

Public Sub UpdateCustomer_DashboardGraphs(ByVal sender As Object, ByVal
e As System.EventArgs)
For Each gvr As GridViewRow In gv_dashboard.Rows
If gvr.RowType = DataControlRowType.DataRow Then

'//--IDs

Dim intCustomerID As String =
CType(gvr.FindControl("lblCustomerID"), Label).Text.Trim()

'//--Textboxes
Dim intBudget As Integer
Try
intBudget = CType(CType(gvr.FindControl("txtBudget"),
TextBox).Text.Trim(), Int32)
Catch
intBudget = 0
End Try

'//--Checkboxes
Dim bolCurrentMonthCollections As Boolean =
CType(gvr.FindControl("chbx_CurrentMonthCollections"), CheckBox).Checked
Dim bolRevenueByMonth As Boolean =
CType(gvr.FindControl("chbx_RevenueByMonth"), CheckBox).Checked
Dim bolPDCsCCsMonthly As Boolean =
CType(gvr.FindControl("chbx_PDCsCCsMonthly"), CheckBox).Checked
Dim bolRevenueByClient As Boolean =
CType(gvr.FindControl("chbx_RevenueByClient"), CheckBox).Checked

'//--Assign UpdateParameters
If bolCurrentMonthCollections = True Then


ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = True
Else

ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = False
End If
If bolRevenueByMonth = True Then

ds_dashboard.UpdateParameters("RevenueByMonth").DefaultValue = True
Else

ds_dashboard.UpdateParameters("RevenueByMonth").DefaultValue = False
End If
If bolPDCsCCsMonthly = True Then

ds_dashboard.UpdateParameters("PDCsCCsMonthly").DefaultValue = True
Else

ds_dashboard.UpdateParameters("PDCsCCsMonthly").DefaultValue = False
End If
If bolRevenueByClient = True Then

ds_dashboard.UpdateParameters("RevenueByClient").DefaultValue = True
Else

ds_dashboard.UpdateParameters("RevenueByClient").DefaultValue = False
End If

ds_dashboard.UpdateParameters("Budget").DefaultValue =
intBudget

ds_dashboard.Update()
End If
Next
End Sub

--
dba123


Karl Seguin said:
you need to check for null. Either don't allow null in that column and use
a default value, use select IsNull(CurrentMonthCollections, false) as
CurrentMonthCollections for selecting a default value, or check for null
before binding, you can do that inline via:

<%# ( Bind("CurrentMonthCollections") == DBNull.Value) ? false : true; %>

Karl
 
Ad

Advertisements

G

Guest

'<%# ( Bind("RevenueByClient") == DBNull.Value) ? false : true; %>'

I've never used that syntax before, didn't even know you could do that so
thatnks, but getting error with your suggestion:



Line 63: <HeaderStyle HorizontalAlign="center"></HeaderStyle>
Line 64: <ItemTemplate>
Line 65: <asp:checkbox runat="server"
Id="chbx_CurrentMonthCollections" Checked='<%# (
Bind("CurrentMonthCollections") == DBNull.Value) ? false : true; %>'/>
Line 66: </ItemTemplate>
Line 67: </asp:TemplateField>


--
dba123


Karl Seguin said:
you need to check for null. Either don't allow null in that column and use
a default value, use select IsNull(CurrentMonthCollections, false) as
CurrentMonthCollections for selecting a default value, or check for null
before binding, you can do that inline via:

<%# ( Bind("CurrentMonthCollections") == DBNull.Value) ? false : true; %>

Karl
 
Ad

Advertisements


Top