469,602 Members | 1,727 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

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 15850
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Paul E Collins | last post: by
3 posts views Thread by Dan Rawson | last post: by
1 post views Thread by Harold Putman | last post: by
11 posts views Thread by Bob Day | last post: by
reply views Thread by guiromero | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.