473,324 Members | 2,313 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

String was not recognized as a valid Boolean

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_CurrentMonthCollection s"), 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("CurrentMonthCollect ions").DefaultValue = 1
Else

ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue = 0
End If
....

ds_dashboard.UpdateParameters("Budget").DefaultVal ue =
intBudget

ds_dashboard.Update()
End If
Next
End Sub
--
dba123
Apr 25 '06 #1
10 16351
which line is the error on?

Karl

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

"dba123" <db****@discussions.microsoft.com> wrote in message
news:0F**********************************@microsof t.com...
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_CurrentMonthCollection s"), 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("CurrentMonthCollect ions").DefaultValue = 1
Else

ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue = 0
End If
...

ds_dashboard.UpdateParameters("Budget").DefaultVal ue =
intBudget

ds_dashboard.Update()
End If
Next
End Sub
--
dba123

Apr 25 '06 #2
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_DashboardGraph s"
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").DefaultVal ue = intBudget
Line 54:
Line 55: ds_dashboard.Update()
Line 56: End If
Line 57: Next
Source File:
Y:\inetpub\wwwroot\apex\webapps\dashboard\dashboar d\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(IForma tProvider provider) +12
System.Convert.ChangeType(Object value, TypeCode typeCode,
IFormatProvider provider) +98
System.Web.UI.WebControls.Parameter.GetValue(Objec t value, String
defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean
ignoreNullableTypeChanges) +257
System.Web.UI.WebControls.Parameter.get_ParameterV alue() +91
System.Web.UI.WebControls.ParameterCollection.GetV alues(HttpContext
context, Control control) +282

System.Web.UI.WebControls.SqlDataSourceView.Initia lizeParameters(DbCommand
command, ParameterCollection parameters, IDictionary exclusionList) +344
System.Web.UI.WebControls.SqlDataSourceView.Execut eUpdate(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.RaisePostBackEven t(String eventArgument)
+116

System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +72
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3837
--
dba123
"Karl Seguin [MVP]" wrote:
which line is the error on?

Karl

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

"dba123" <db****@discussions.microsoft.com> wrote in message
news:0F**********************************@microsof t.com...
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_CurrentMonthCollection s"), 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("CurrentMonthCollect ions").DefaultValue = 1
Else

ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue = 0
End If
...

ds_dashboard.UpdateParameters("Budget").DefaultVal ue =
intBudget

ds_dashboard.Update()
End If
Next
End Sub
--
dba123


Apr 25 '06 #3
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("CurrentMonthCollect ions").DefaultValue = 1
Else

ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue = 0
End If

to

If intCurrentMonthCollections = True Then

ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue = "true"
Else

ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue =
"false"
End If

The error goes away but it's still not updating those bit fields in my table
--
dba123
"dba123" wrote:
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_DashboardGraph s"
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").DefaultVal ue = intBudget
Line 54:
Line 55: ds_dashboard.Update()
Line 56: End If
Line 57: Next
Source File:
Y:\inetpub\wwwroot\apex\webapps\dashboard\dashboar d\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(IForma tProvider provider) +12
System.Convert.ChangeType(Object value, TypeCode typeCode,
IFormatProvider provider) +98
System.Web.UI.WebControls.Parameter.GetValue(Objec t value, String
defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean
ignoreNullableTypeChanges) +257
System.Web.UI.WebControls.Parameter.get_ParameterV alue() +91
System.Web.UI.WebControls.ParameterCollection.GetV alues(HttpContext
context, Control control) +282

System.Web.UI.WebControls.SqlDataSourceView.Initia lizeParameters(DbCommand
command, ParameterCollection parameters, IDictionary exclusionList) +344
System.Web.UI.WebControls.SqlDataSourceView.Execut eUpdate(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.RaisePostBackEven t(String eventArgument)
+116

System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +72
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3837
--
dba123
"Karl Seguin [MVP]" wrote:
which line is the error on?

Karl

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

"dba123" <db****@discussions.microsoft.com> wrote in message
news:0F**********************************@microsof t.com...
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_CurrentMonthCollection s"), 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("CurrentMonthCollect ions").DefaultValue = 1
Else

ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue = 0
End If
...

ds_dashboard.UpdateParameters("Budget").DefaultVal ue =
intBudget

ds_dashboard.Update()
End If
Next
End Sub
--
dba123


Apr 25 '06 #4
Why don't you just set it to true/false instead of "true"/"fale"

ds_dashboard.UpdateParameters("CurrentMonthCollect ions").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" <db****@discussions.microsoft.com> wrote in message
news:46**********************************@microsof t.com...
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("CurrentMonthCollect ions").DefaultValue = 1
Else

ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue = 0
End If

to

If intCurrentMonthCollections = True Then

ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue =
"true"
Else

ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue =
"false"
End If

The error goes away but it's still not updating those bit fields in my
table
--
dba123
"dba123" wrote:
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_DashboardGraph s"
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").DefaultVal ue = intBudget
Line 54:
Line 55: ds_dashboard.Update()
Line 56: End If
Line 57: Next
Source File:
Y:\inetpub\wwwroot\apex\webapps\dashboard\dashboar d\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(IForma tProvider provider)
+12
System.Convert.ChangeType(Object value, TypeCode typeCode,
IFormatProvider provider) +98
System.Web.UI.WebControls.Parameter.GetValue(Objec t value, String
defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean
ignoreNullableTypeChanges) +257
System.Web.UI.WebControls.Parameter.get_ParameterV alue() +91
System.Web.UI.WebControls.ParameterCollection.GetV alues(HttpContext
context, Control control) +282

System.Web.UI.WebControls.SqlDataSourceView.Initia lizeParameters(DbCommand
command, ParameterCollection parameters, IDictionary exclusionList) +344
System.Web.UI.WebControls.SqlDataSourceView.Execut eUpdate(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.RaisePostBackEven t(String
eventArgument)
+116

System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
+72
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+3837
--
dba123
"Karl Seguin [MVP]" wrote:
> which line is the error on?
>
> Karl
>
> --
> http://www.openmymind.net/
>
>
>
> "dba123" <db****@discussions.microsoft.com> wrote in message
> news:0F**********************************@microsof t.com...
> > 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_CurrentMonthCollection s"),
> > 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("CurrentMonthCollect ions").DefaultValue
> > = 1
> > Else
> >
> > ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue
> > = 0
> > End If
> > ...
> >
> > ds_dashboard.UpdateParameters("Budget").DefaultVal ue =
> > intBudget
> >
> > ds_dashboard.Update()
> > End If
> > Next
> > End Sub
> > --
> > dba123
>
>
>

Apr 25 '06 #5
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.
--
dba123
"dba123" wrote:
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_CurrentMonthCollection s"), 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("CurrentMonthCollect ions").DefaultValue = 1
Else

ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue = 0
End If
...

ds_dashboard.UpdateParameters("Budget").DefaultVal ue =
intBudget

ds_dashboard.Update()
End If
Next
End Sub
--
dba123

Apr 25 '06 #6
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 [MVP]" wrote:
Why don't you just set it to true/false instead of "true"/"fale"

ds_dashboard.UpdateParameters("CurrentMonthCollect ions").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" <db****@discussions.microsoft.com> wrote in message
news:46**********************************@microsof t.com...
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("CurrentMonthCollect ions").DefaultValue = 1
Else

ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue = 0
End If

to

If intCurrentMonthCollections = True Then

ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue =
"true"
Else

ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue =
"false"
End If

The error goes away but it's still not updating those bit fields in my
table
--
dba123
"dba123" wrote:
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_DashboardGraph s"
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").DefaultVal ue = intBudget
Line 54:
Line 55: ds_dashboard.Update()
Line 56: End If
Line 57: Next
Source File:
Y:\inetpub\wwwroot\apex\webapps\dashboard\dashboar d\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(IForma tProvider provider)
+12
System.Convert.ChangeType(Object value, TypeCode typeCode,
IFormatProvider provider) +98
System.Web.UI.WebControls.Parameter.GetValue(Objec t value, String
defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean
ignoreNullableTypeChanges) +257
System.Web.UI.WebControls.Parameter.get_ParameterV alue() +91
System.Web.UI.WebControls.ParameterCollection.GetV alues(HttpContext
context, Control control) +282

System.Web.UI.WebControls.SqlDataSourceView.Initia lizeParameters(DbCommand
command, ParameterCollection parameters, IDictionary exclusionList) +344
System.Web.UI.WebControls.SqlDataSourceView.Execut eUpdate(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.RaisePostBackEven t(String
eventArgument)
+116

System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
+72
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+3837
--
dba123
"Karl Seguin [MVP]" wrote:

> which line is the error on?
>
> Karl
>
> --
> http://www.openmymind.net/
>
>
>
> "dba123" <db****@discussions.microsoft.com> wrote in message
> news:0F**********************************@microsof t.com...
> > 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

Apr 25 '06 #7
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 [MVP]" wrote:
Why don't you just set it to true/false instead of "true"/"fale"

ds_dashboard.UpdateParameters("CurrentMonthCollect ions").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" <db****@discussions.microsoft.com> wrote in message
news:46**********************************@microsof t.com...
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("CurrentMonthCollect ions").DefaultValue = 1
Else

ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue = 0
End If

to

If intCurrentMonthCollections = True Then

ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue =
"true"
Else

ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue =
"false"
End If

The error goes away but it's still not updating those bit fields in my
table
--
dba123
"dba123" wrote:
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_DashboardGraph s"
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").DefaultVal ue = intBudget
Line 54:
Line 55: ds_dashboard.Update()
Line 56: End If
Line 57: Next
Source File:
Y:\inetpub\wwwroot\apex\webapps\dashboard\dashboar d\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(IForma tProvider provider)
+12
System.Convert.ChangeType(Object value, TypeCode typeCode,
IFormatProvider provider) +98
System.Web.UI.WebControls.Parameter.GetValue(Objec t value, String
defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean
ignoreNullableTypeChanges) +257
System.Web.UI.WebControls.Parameter.get_ParameterV alue() +91
System.Web.UI.WebControls.ParameterCollection.GetV alues(HttpContext
context, Control control) +282

System.Web.UI.WebControls.SqlDataSourceView.Initia lizeParameters(DbCommand
command, ParameterCollection parameters, IDictionary exclusionList) +344
System.Web.UI.WebControls.SqlDataSourceView.Execut eUpdate(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.RaisePostBackEven t(String
eventArgument)
+116

System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +31
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +32
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
+72
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+3837
--
dba123
"Karl Seguin [MVP]" wrote:

> which line is the error on?
>
> Karl
>
> --
> http://www.openmymind.net/
>
>
>
> "dba123" <db****@discussions.microsoft.com> wrote in message
> news:0F**********************************@microsof t.com...
> > 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

Apr 25 '06 #8
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

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"dba123" <db****@discussions.microsoft.com> wrote in message
news:57**********************************@microsof t.com...
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.
--
dba123
"dba123" wrote:
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_CurrentMonthCollection s"), 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("CurrentMonthCollect ions").DefaultValue = 1
Else

ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue = 0
End If
...

ds_dashboard.UpdateParameters("Budget").DefaultVal ue =
intBudget

ds_dashboard.Update()
End If
Next
End Sub
--
dba123

Apr 25 '06 #9
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_DashboardGraph s"
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_CurrentMonthCollection s"), 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("CurrentMonthCollect ions").DefaultValue = True
Else

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

ds_dashboard.UpdateParameters("RevenueByMonth").De faultValue = True
Else

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

ds_dashboard.UpdateParameters("PDCsCCsMonthly").De faultValue = True
Else

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

ds_dashboard.UpdateParameters("RevenueByClient").D efaultValue = True
Else

ds_dashboard.UpdateParameters("RevenueByClient").D efaultValue = False
End If

ds_dashboard.UpdateParameters("Budget").DefaultVal ue =
intBudget

ds_dashboard.Update()
End If
Next
End Sub

--
dba123
"Karl Seguin [MVP]" wrote:
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

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"dba123" <db****@discussions.microsoft.com> wrote in message
news:57**********************************@microsof t.com...
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.
--
dba123
"dba123" wrote:
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_CurrentMonthCollection s"), 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("CurrentMonthCollect ions").DefaultValue = 1
Else

ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue = 0
End If
...

ds_dashboard.UpdateParameters("Budget").DefaultVal ue =
intBudget

ds_dashboard.Update()
End If
Next
End Sub
--
dba123


Apr 25 '06 #10
'<%# ( 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 [MVP]" wrote:
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

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"dba123" <db****@discussions.microsoft.com> wrote in message
news:57**********************************@microsof t.com...
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.
--
dba123
"dba123" wrote:
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_CurrentMonthCollection s"), 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("CurrentMonthCollect ions").DefaultValue = 1
Else

ds_dashboard.UpdateParameters("CurrentMonthCollect ions").DefaultValue = 0
End If
...

ds_dashboard.UpdateParameters("Budget").DefaultVal ue =
intBudget

ds_dashboard.Update()
End If
Next
End Sub
--
dba123


Apr 25 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Paul E Collins | last post by:
Given a string variable (form input), how can I determine whether it represents a valid integer? is_numeric is true for floats as well as integers, and is_int always fails on a string. P.
3
by: Dan Rawson | last post by:
I need to return "True" or "False" strings for a boolean value (mostly for display purposes). It's obviously trivial to write the function: def bStr (bVar): if bVar: return 'True' else:...
1
by: Harold Putman | last post by:
Is there a way to check a string to see if it is a valid XML Name according to the definition in the XML specifiction (http://www.w3.org/TR/REC-xml#dt-name). I wrote code to do this by hand but...
11
by: Bob Day | last post by:
The IsDate code below should result in False, instead it throws the exception below. Why? How do I check if a string can be converted to a date if this function does not work properly? Bob ...
5
by: jason | last post by:
Though this code appears to work, I suspect it could be streamline. Total Noob Here. public bool isit(string c1) { string color1 = "blue green red"; Regex re = new Regex("@"+c1,...
2
by: Carlos Aguayo | last post by:
Hi, Is there a better way to do this? The problem that I have is that x can be "true" or "false" (as type string), or true or false (as boolean type). I'm doing comparisons like... if (eval(x)...
3
by: c2 | last post by:
hi, i face a problem when click the icon , my login will prompt this message String was not recognized as a valid Boolean See the end of this message for details on invoking just-in-time (JIT)...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.