473,883 Members | 1,590 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

String was not recognized as a valid Boolean

Why am I getting this error for Budget?

Error: An exception of type 'System.FormatE xception' 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.EventArg s)
For Each gvr As GridViewRow In gv_dashboard.Ro ws
If gvr.RowType = DataControlRowT ype.DataRow Then

'//--IDs

Dim intCustomerID As String =
CType(gvr.FindC ontrol("lblCust omerID"), Label).Text.Tri m()

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

'//--Checkboxes
Dim intCurrentMonth Collections As Boolean =
CType(gvr.FindC ontrol("chbx_Cu rrentMonthColle ctions"), CheckBox).Check ed
Dim intRevenueByMon th As Boolean =
CType(gvr.FindC ontrol("chbx_Re venueByMonth"), CheckBox).Check ed
Dim intPDCsCCsMonth ly As Boolean =
CType(gvr.FindC ontrol("chbx_PD CsCCsMonthly"), CheckBox).Check ed
Dim intRevenueByCli ent As Boolean =
CType(gvr.FindC ontrol("chbx_Re venueByClient") , CheckBox).Check ed

'//--Assign UpdateParameter s
If intCurrentMonth Collections = True Then

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = 1
Else

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = 0
End If
....

ds_dashboard.Up dateParameters( "Budget").Defau ltValue =
intBudget

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

Karl

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

"dba123" <db****@discuss ions.microsoft. com> wrote in message
news:0F******** *************** ***********@mic rosoft.com...
Why am I getting this error for Budget?

Error: An exception of type 'System.FormatE xception' 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.EventArg s)
For Each gvr As GridViewRow In gv_dashboard.Ro ws
If gvr.RowType = DataControlRowT ype.DataRow Then

'//--IDs

Dim intCustomerID As String =
CType(gvr.FindC ontrol("lblCust omerID"), Label).Text.Tri m()

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

'//--Checkboxes
Dim intCurrentMonth Collections As Boolean =
CType(gvr.FindC ontrol("chbx_Cu rrentMonthColle ctions"), CheckBox).Check ed
Dim intRevenueByMon th As Boolean =
CType(gvr.FindC ontrol("chbx_Re venueByMonth"), CheckBox).Check ed
Dim intPDCsCCsMonth ly As Boolean =
CType(gvr.FindC ontrol("chbx_PD CsCCsMonthly"), CheckBox).Check ed
Dim intRevenueByCli ent As Boolean =
CType(gvr.FindC ontrol("chbx_Re venueByClient") , CheckBox).Check ed

'//--Assign UpdateParameter s
If intCurrentMonth Collections = True Then

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = 1
Else

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = 0
End If
...

ds_dashboard.Up dateParameters( "Budget").Defau ltValue =
intBudget

ds_dashboard.Up date()
End If
Next
End Sub
--
dba123

Apr 25 '06 #2
String was not recognized as a valid Boolean

For Line: ds_dashboard.Up date() in my update function
My SQLDataSource:
-------------------------

<asp:SqlDataSou rce
ID="ds_dashboar d"
runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:DashboardCon n %>"
SelectCommand=" aspx_Get_Custom er_DashboardGra phs"
SelectCommandTy pe="StoredProce dure"
UpdateCommand=" aspx_Update_Cus tomer_Dashboard Graphs"
UpdateCommandTy pe="StoredProce dure"
<UpdateParamete rs>
<asp:Paramete r Name="CustomerI D" Type="Int32" />
<asp:Paramete r Name="Budget" Type="Int32" />
<asp:Paramete r Name="CurrentMo nthCollections"
Type="Boolean" />
<asp:Paramete r Name="RevenueBy Month" Type="Boolean" />
<asp:Paramete r Name="PDCsCCsMo nthly" Type="Boolean" />
<asp:Paramete r Name="RevenueBy Client" Type="Boolean" />

</UpdateParameter s>

</asp:SqlDataSour ce>
My GridView:
---------------------

<asp:GridView
ID="gv_dashboar d"
runat="server"
AutoGenerateCol umns="False"
DataSourceID="d s_dashboard"
CellPadding="4"
ForeColor="#333 333"
ShowFooter="Tru e"
GridLines="None "
CssClass="Forma tFont">

<Columns>
<asp:TemplateFi eld HeaderText="Cus t #"
SortExpression= "CustomerID ">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:Label runat="server" id="lblCustomer ID"
Text='<%# Bind("Customer" ) %>' />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Bud get" 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:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Cur rent Month Collections"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_Curren tMonthCollectio ns" />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Rev enue By Month"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_Revenu eByMonth" />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="PDC s & CCS Monthly"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_PDCsCC sMonthly" />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Rev enue By Client"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_Revenu eByClient" />
</ItemTemplate>
</asp:TemplateFie ld>
</Columns>

<FooterStyle BackColor="#5D7 B9D" Font-Bold="True"
ForeColor="Whit e" />
<RowStyle BackColor="#F7F 6F3" ForeColor="#333 333" />
<EditRowStyle BackColor="#DDD DDD" />
<SelectedRowSty le BackColor="#DDD DDD" Font-Bold="True"
ForeColor="#333 333" />
<PagerStyle BackColor="#284 775" ForeColor="Whit e"
HorizontalAlign ="Center" />
<HeaderStyle BackColor="#5D7 B9D" Font-Bold="True"
ForeColor="Whit e" />
<AlternatingRow Style BackColor="Whit e" ForeColor="#284 775" />
</asp:GridView>
My Update Command (Stored Procedure):
--------------------------------------------------

ALTER PROCEDURE [dbo].[aspx_Update_Cus tomer_Dashboard Graphs]

@CustomerID bigint,
@Budget int,
@CurrentMonthCo llections bit,
@RevenueByMonth bit,
@PDCsCCsMonthly bit,
@RevenueByClien t bit

AS
BEGIN

UPDATE dbo.Customer_Da shboardGraphs
SET Budget = @Budget,
CurrentMonthCol lections = @CurrentMonthCo llections,
RevenueByMonth = @RevenueByMonth ,
PDCsCCsMonthly = @PDCsCCsMonthly ,
RevenueByClient = @RevenueByClien t
WHERE Customer_Dashbo ardGraphs.Custo mer = @CustomerID
END
My Table Schema:
-----------------------

CREATE TABLE [dbo].[Customer_Dashbo ardGraphs](
[Customer] [nchar](10) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS NULL,
[DashboardGraphI D] [bit] NULL,
[CurrentMonthCol lections] [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.FormatEx ception: String was not recognized as a
valid Boolean.

Source Error:
Line 53:
ds_dashboard.Up dateParameters( "Budget").Defau ltValue = intBudget
Line 54:
Line 55: ds_dashboard.Up date()
Line 56: End If
Line 57: Next
Source File:
Y:\inetpub\wwwr oot\apex\webapp s\dashboard\das hboard\index.as px.vb Line: 55
Stack Trace:
------------------

[FormatException : String was not recognized as a valid Boolean.]
System.Boolean. Parse(String value) +2709172
System.String.S ystem.IConverti ble.ToBoolean(I FormatProvider provider) +12
System.Convert. ChangeType(Obje ct value, TypeCode typeCode,
IFormatProvider provider) +98
System.Web.UI.W ebControls.Para meter.GetValue( Object value, String
defaultValue, TypeCode type, Boolean convertEmptyStr ingToNull, Boolean
ignoreNullableT ypeChanges) +257
System.Web.UI.W ebControls.Para meter.get_Param eterValue() +91
System.Web.UI.W ebControls.Para meterCollection .GetValues(Http Context
context, Control control) +282

System.Web.UI.W ebControls.SqlD ataSourceView.I nitializeParame ters(DbCommand
command, ParameterCollec tion parameters, IDictionary exclusionList) +344
System.Web.UI.W ebControls.SqlD ataSourceView.E xecuteUpdate(ID ictionary
keys, IDictionary values, IDictionary oldValues) +449
System.Web.UI.W ebControls.SqlD ataSourceView.U pdate(IDictiona ry keys,
IDictionary values, IDictionary oldValues) +37
System.Web.UI.W ebControls.SqlD ataSource.Updat e() +42
dashboard._Defa ult.UpdateCusto mer_DashboardGr aphs(Object sender,
EventArgs e) in
Y:\inetpub\wwwr oot\sss\webapps \dashboard\dash board\index.asp x.vb:55
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +96
System.Web.UI.W ebControls.Butt on.RaisePostBac kEvent(String eventArgument)
+116

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring eventArgument) +31
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +32
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +72
System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint) +3837
--
dba123
"Karl Seguin [MVP]" wrote:
which line is the error on?

Karl

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

"dba123" <db****@discuss ions.microsoft. com> wrote in message
news:0F******** *************** ***********@mic rosoft.com...
Why am I getting this error for Budget?

Error: An exception of type 'System.FormatE xception' 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.EventArg s)
For Each gvr As GridViewRow In gv_dashboard.Ro ws
If gvr.RowType = DataControlRowT ype.DataRow Then

'//--IDs

Dim intCustomerID As String =
CType(gvr.FindC ontrol("lblCust omerID"), Label).Text.Tri m()

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

'//--Checkboxes
Dim intCurrentMonth Collections As Boolean =
CType(gvr.FindC ontrol("chbx_Cu rrentMonthColle ctions"), CheckBox).Check ed
Dim intRevenueByMon th As Boolean =
CType(gvr.FindC ontrol("chbx_Re venueByMonth"), CheckBox).Check ed
Dim intPDCsCCsMonth ly As Boolean =
CType(gvr.FindC ontrol("chbx_PD CsCCsMonthly"), CheckBox).Check ed
Dim intRevenueByCli ent As Boolean =
CType(gvr.FindC ontrol("chbx_Re venueByClient") , CheckBox).Check ed

'//--Assign UpdateParameter s
If intCurrentMonth Collections = True Then

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = 1
Else

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = 0
End If
...

ds_dashboard.Up dateParameters( "Budget").Defau ltValue =
intBudget

ds_dashboard.Up date()
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 intCurrentMonth Collections = True Then

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = 1
Else

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = 0
End If

to

If intCurrentMonth Collections = True Then

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = "true"
Else

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue =
"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.Up date() in my update function
My SQLDataSource:
-------------------------

<asp:SqlDataSou rce
ID="ds_dashboar d"
runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:DashboardCon n %>"
SelectCommand=" aspx_Get_Custom er_DashboardGra phs"
SelectCommandTy pe="StoredProce dure"
UpdateCommand=" aspx_Update_Cus tomer_Dashboard Graphs"
UpdateCommandTy pe="StoredProce dure"
>

<UpdateParamete rs>
<asp:Paramete r Name="CustomerI D" Type="Int32" />
<asp:Paramete r Name="Budget" Type="Int32" />
<asp:Paramete r Name="CurrentMo nthCollections"
Type="Boolean" />
<asp:Paramete r Name="RevenueBy Month" Type="Boolean" />
<asp:Paramete r Name="PDCsCCsMo nthly" Type="Boolean" />
<asp:Paramete r Name="RevenueBy Client" Type="Boolean" />

</UpdateParameter s>

</asp:SqlDataSour ce>
My GridView:
---------------------

<asp:GridView
ID="gv_dashboar d"
runat="server"
AutoGenerateCol umns="False"
DataSourceID="d s_dashboard"
CellPadding="4"
ForeColor="#333 333"
ShowFooter="Tru e"
GridLines="None "
CssClass="Forma tFont">

<Columns>
<asp:TemplateFi eld HeaderText="Cus t #"
SortExpression= "CustomerID ">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:Label runat="server" id="lblCustomer ID"
Text='<%# Bind("Customer" ) %>' />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Bud get" 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:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Cur rent Month Collections"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_Curren tMonthCollectio ns" />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Rev enue By Month"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_Revenu eByMonth" />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="PDC s & CCS Monthly"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_PDCsCC sMonthly" />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Rev enue By Client"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_Revenu eByClient" />
</ItemTemplate>
</asp:TemplateFie ld>
</Columns>

<FooterStyle BackColor="#5D7 B9D" Font-Bold="True"
ForeColor="Whit e" />
<RowStyle BackColor="#F7F 6F3" ForeColor="#333 333" />
<EditRowStyle BackColor="#DDD DDD" />
<SelectedRowSty le BackColor="#DDD DDD" Font-Bold="True"
ForeColor="#333 333" />
<PagerStyle BackColor="#284 775" ForeColor="Whit e"
HorizontalAlign ="Center" />
<HeaderStyle BackColor="#5D7 B9D" Font-Bold="True"
ForeColor="Whit e" />
<AlternatingRow Style BackColor="Whit e" ForeColor="#284 775" />
</asp:GridView>
My Update Command (Stored Procedure):
--------------------------------------------------

ALTER PROCEDURE [dbo].[aspx_Update_Cus tomer_Dashboard Graphs]

@CustomerID bigint,
@Budget int,
@CurrentMonthCo llections bit,
@RevenueByMonth bit,
@PDCsCCsMonthly bit,
@RevenueByClien t bit

AS
BEGIN

UPDATE dbo.Customer_Da shboardGraphs
SET Budget = @Budget,
CurrentMonthCol lections = @CurrentMonthCo llections,
RevenueByMonth = @RevenueByMonth ,
PDCsCCsMonthly = @PDCsCCsMonthly ,
RevenueByClient = @RevenueByClien t
WHERE Customer_Dashbo ardGraphs.Custo mer = @CustomerID
END
My Table Schema:
-----------------------

CREATE TABLE [dbo].[Customer_Dashbo ardGraphs](
[Customer] [nchar](10) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS NULL,
[DashboardGraphI D] [bit] NULL,
[CurrentMonthCol lections] [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.FormatEx ception: String was not recognized as a
valid Boolean.

Source Error:
Line 53:
ds_dashboard.Up dateParameters( "Budget").Defau ltValue = intBudget
Line 54:
Line 55: ds_dashboard.Up date()
Line 56: End If
Line 57: Next
Source File:
Y:\inetpub\wwwr oot\apex\webapp s\dashboard\das hboard\index.as px.vb Line: 55
Stack Trace:
------------------

[FormatException : String was not recognized as a valid Boolean.]
System.Boolean. Parse(String value) +2709172
System.String.S ystem.IConverti ble.ToBoolean(I FormatProvider provider) +12
System.Convert. ChangeType(Obje ct value, TypeCode typeCode,
IFormatProvider provider) +98
System.Web.UI.W ebControls.Para meter.GetValue( Object value, String
defaultValue, TypeCode type, Boolean convertEmptyStr ingToNull, Boolean
ignoreNullableT ypeChanges) +257
System.Web.UI.W ebControls.Para meter.get_Param eterValue() +91
System.Web.UI.W ebControls.Para meterCollection .GetValues(Http Context
context, Control control) +282

System.Web.UI.W ebControls.SqlD ataSourceView.I nitializeParame ters(DbCommand
command, ParameterCollec tion parameters, IDictionary exclusionList) +344
System.Web.UI.W ebControls.SqlD ataSourceView.E xecuteUpdate(ID ictionary
keys, IDictionary values, IDictionary oldValues) +449
System.Web.UI.W ebControls.SqlD ataSourceView.U pdate(IDictiona ry keys,
IDictionary values, IDictionary oldValues) +37
System.Web.UI.W ebControls.SqlD ataSource.Updat e() +42
dashboard._Defa ult.UpdateCusto mer_DashboardGr aphs(Object sender,
EventArgs e) in
Y:\inetpub\wwwr oot\sss\webapps \dashboard\dash board\index.asp x.vb:55
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +96
System.Web.UI.W ebControls.Butt on.RaisePostBac kEvent(String eventArgument)
+116

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring eventArgument) +31
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +32
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +72
System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint) +3837
--
dba123
"Karl Seguin [MVP]" wrote:
which line is the error on?

Karl

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

"dba123" <db****@discuss ions.microsoft. com> wrote in message
news:0F******** *************** ***********@mic rosoft.com...
Why am I getting this error for Budget?

Error: An exception of type 'System.FormatE xception' 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.EventArg s)
For Each gvr As GridViewRow In gv_dashboard.Ro ws
If gvr.RowType = DataControlRowT ype.DataRow Then

'//--IDs

Dim intCustomerID As String =
CType(gvr.FindC ontrol("lblCust omerID"), Label).Text.Tri m()

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

'//--Checkboxes
Dim intCurrentMonth Collections As Boolean =
CType(gvr.FindC ontrol("chbx_Cu rrentMonthColle ctions"), CheckBox).Check ed
Dim intRevenueByMon th As Boolean =
CType(gvr.FindC ontrol("chbx_Re venueByMonth"), CheckBox).Check ed
Dim intPDCsCCsMonth ly As Boolean =
CType(gvr.FindC ontrol("chbx_PD CsCCsMonthly"), CheckBox).Check ed
Dim intRevenueByCli ent As Boolean =
CType(gvr.FindC ontrol("chbx_Re venueByClient") , CheckBox).Check ed

'//--Assign UpdateParameter s
If intCurrentMonth Collections = True Then

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = 1
Else

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = 0
End If
...

ds_dashboard.Up dateParameters( "Budget").Defau ltValue =
intBudget

ds_dashboard.Up date()
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.Up dateParameters( "CurrentMonthCo llections").Def aultValue =
intCurrentMonth Collections

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****@discuss ions.microsoft. com> wrote in message
news:46******** *************** ***********@mic rosoft.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 intCurrentMonth Collections = True Then

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = 1
Else

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = 0
End If

to

If intCurrentMonth Collections = True Then

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue =
"true"
Else

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue =
"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.Up date() in my update function
My SQLDataSource:
-------------------------

<asp:SqlDataSou rce
ID="ds_dashboar d"
runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:DashboardCon n %>"
SelectCommand=" aspx_Get_Custom er_DashboardGra phs"
SelectCommandTy pe="StoredProce dure"
UpdateCommand=" aspx_Update_Cus tomer_Dashboard Graphs"
UpdateCommandTy pe="StoredProce dure"
>

<UpdateParamete rs>
<asp:Paramete r Name="CustomerI D" Type="Int32" />
<asp:Paramete r Name="Budget" Type="Int32" />
<asp:Paramete r Name="CurrentMo nthCollections"
Type="Boolean" />
<asp:Paramete r Name="RevenueBy Month" Type="Boolean"
/>
<asp:Paramete r Name="PDCsCCsMo nthly" Type="Boolean"
/>
<asp:Paramete r Name="RevenueBy Client" Type="Boolean"
/>

</UpdateParameter s>

</asp:SqlDataSour ce>
My GridView:
---------------------

<asp:GridView
ID="gv_dashboar d"
runat="server"
AutoGenerateCol umns="False"
DataSourceID="d s_dashboard"
CellPadding="4"
ForeColor="#333 333"
ShowFooter="Tru e"
GridLines="None "
CssClass="Forma tFont">

<Columns>
<asp:TemplateFi eld HeaderText="Cus t #"
SortExpression= "CustomerID ">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:Label runat="server" id="lblCustomer ID"
Text='<%# Bind("Customer" ) %>' />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Bud get"
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:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Cur rent Month Collections"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_Curren tMonthCollectio ns" />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Rev enue By Month"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_Revenu eByMonth" />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="PDC s & CCS Monthly"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_PDCsCC sMonthly" />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Rev enue By Client"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_Revenu eByClient" />
</ItemTemplate>
</asp:TemplateFie ld>
</Columns>

<FooterStyle BackColor="#5D7 B9D" Font-Bold="True"
ForeColor="Whit e" />
<RowStyle BackColor="#F7F 6F3" ForeColor="#333 333" />
<EditRowStyle BackColor="#DDD DDD" />
<SelectedRowSty le BackColor="#DDD DDD" Font-Bold="True"
ForeColor="#333 333" />
<PagerStyle BackColor="#284 775" ForeColor="Whit e"
HorizontalAlign ="Center" />
<HeaderStyle BackColor="#5D7 B9D" Font-Bold="True"
ForeColor="Whit e" />
<AlternatingRow Style BackColor="Whit e" ForeColor="#284 775" />
</asp:GridView>
My Update Command (Stored Procedure):
--------------------------------------------------

ALTER PROCEDURE [dbo].[aspx_Update_Cus tomer_Dashboard Graphs]

@CustomerID bigint,
@Budget int,
@CurrentMonthCo llections bit,
@RevenueByMonth bit,
@PDCsCCsMonthly bit,
@RevenueByClien t bit

AS
BEGIN

UPDATE dbo.Customer_Da shboardGraphs
SET Budget = @Budget,
CurrentMonthCol lections = @CurrentMonthCo llections,
RevenueByMonth = @RevenueByMonth ,
PDCsCCsMonthly = @PDCsCCsMonthly ,
RevenueByClient = @RevenueByClien t
WHERE Customer_Dashbo ardGraphs.Custo mer = @CustomerID
END
My Table Schema:
-----------------------

CREATE TABLE [dbo].[Customer_Dashbo ardGraphs](
[Customer] [nchar](10) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS NULL,
[DashboardGraphI D] [bit] NULL,
[CurrentMonthCol lections] [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.FormatEx ception: String was not recognized as a
valid Boolean.

Source Error:
Line 53:
ds_dashboard.Up dateParameters( "Budget").Defau ltValue = intBudget
Line 54:
Line 55: ds_dashboard.Up date()
Line 56: End If
Line 57: Next
Source File:
Y:\inetpub\wwwr oot\apex\webapp s\dashboard\das hboard\index.as px.vb
Line: 55
Stack Trace:
------------------

[FormatException : String was not recognized as a valid Boolean.]
System.Boolean. Parse(String value) +2709172
System.String.S ystem.IConverti ble.ToBoolean(I FormatProvider provider)
+12
System.Convert. ChangeType(Obje ct value, TypeCode typeCode,
IFormatProvider provider) +98
System.Web.UI.W ebControls.Para meter.GetValue( Object value, String
defaultValue, TypeCode type, Boolean convertEmptyStr ingToNull, Boolean
ignoreNullableT ypeChanges) +257
System.Web.UI.W ebControls.Para meter.get_Param eterValue() +91
System.Web.UI.W ebControls.Para meterCollection .GetValues(Http Context
context, Control control) +282

System.Web.UI.W ebControls.SqlD ataSourceView.I nitializeParame ters(DbCommand
command, ParameterCollec tion parameters, IDictionary exclusionList) +344
System.Web.UI.W ebControls.SqlD ataSourceView.E xecuteUpdate(ID ictionary
keys, IDictionary values, IDictionary oldValues) +449
System.Web.UI.W ebControls.SqlD ataSourceView.U pdate(IDictiona ry keys,
IDictionary values, IDictionary oldValues) +37
System.Web.UI.W ebControls.SqlD ataSource.Updat e() +42
dashboard._Defa ult.UpdateCusto mer_DashboardGr aphs(Object sender,
EventArgs e) in
Y:\inetpub\wwwr oot\sss\webapps \dashboard\dash board\index.asp x.vb:55
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +96
System.Web.UI.W ebControls.Butt on.RaisePostBac kEvent(String
eventArgument)
+116

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument) +31
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +32
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
+72
System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
+3837
--
dba123
"Karl Seguin [MVP]" wrote:
> which line is the error on?
>
> Karl
>
> --
> http://www.openmymind.net/
>
>
>
> "dba123" <db****@discuss ions.microsoft. com> wrote in message
> news:0F******** *************** ***********@mic rosoft.com...
> > Why am I getting this error for Budget?
> >
> > Error: An exception of type 'System.FormatE xception' 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.EventArg s)
> > For Each gvr As GridViewRow In gv_dashboard.Ro ws
> > If gvr.RowType = DataControlRowT ype.DataRow Then
> >
> > '//--IDs
> >
> > Dim intCustomerID As String =
> > CType(gvr.FindC ontrol("lblCust omerID"), Label).Text.Tri m()
> >
> > '//--Textboxes
> > Dim intBudget As Integer
> > Try
> > intBudget =
> > CType(CType(gvr .FindControl("t xtBudget"),
> > TextBox).Text.T rim(), Int32)
> > Catch
> > intBudget = CType(0, Int32)
> > End Try
> >
> > '//--Checkboxes
> > Dim intCurrentMonth Collections As Boolean =
> > CType(gvr.FindC ontrol("chbx_Cu rrentMonthColle ctions"),
> > CheckBox).Check ed
> > Dim intRevenueByMon th As Boolean =
> > CType(gvr.FindC ontrol("chbx_Re venueByMonth"), CheckBox).Check ed
> > Dim intPDCsCCsMonth ly As Boolean =
> > CType(gvr.FindC ontrol("chbx_PD CsCCsMonthly"), CheckBox).Check ed
> > Dim intRevenueByCli ent As Boolean =
> > CType(gvr.FindC ontrol("chbx_Re venueByClient") , CheckBox).Check ed
> >
> > '//--Assign UpdateParameter s
> > If intCurrentMonth Collections = True Then
> >
> > ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue
> > = 1
> > Else
> >
> > ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue
> > = 0
> > End If
> > ...
> >
> > ds_dashboard.Up dateParameters( "Budget").Defau ltValue =
> > intBudget
> >
> > ds_dashboard.Up date()
> > 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_Curren tMonthCollectio ns" Checked='<%#
Bind("CurrentMo nthCollections" ) %>'/>
</ItemTemplate>
</asp:TemplateFie ld>

Error: An exception of type 'System.Invalid CastException' occurred in
Microsoft.Visua lBasic.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.FormatE xception' 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.EventArg s)
For Each gvr As GridViewRow In gv_dashboard.Ro ws
If gvr.RowType = DataControlRowT ype.DataRow Then

'//--IDs

Dim intCustomerID As String =
CType(gvr.FindC ontrol("lblCust omerID"), Label).Text.Tri m()

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

'//--Checkboxes
Dim intCurrentMonth Collections As Boolean =
CType(gvr.FindC ontrol("chbx_Cu rrentMonthColle ctions"), CheckBox).Check ed
Dim intRevenueByMon th As Boolean =
CType(gvr.FindC ontrol("chbx_Re venueByMonth"), CheckBox).Check ed
Dim intPDCsCCsMonth ly As Boolean =
CType(gvr.FindC ontrol("chbx_PD CsCCsMonthly"), CheckBox).Check ed
Dim intRevenueByCli ent As Boolean =
CType(gvr.FindC ontrol("chbx_Re venueByClient") , CheckBox).Check ed

'//--Assign UpdateParameter s
If intCurrentMonth Collections = True Then

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = 1
Else

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = 0
End If
...

ds_dashboard.Up dateParameters( "Budget").Defau ltValue =
intBudget

ds_dashboard.Up date()
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.Up dateParameters( "CurrentMonthCo llections").Def aultValue =
intCurrentMonth Collections

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****@discuss ions.microsoft. com> wrote in message
news:46******** *************** ***********@mic rosoft.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 intCurrentMonth Collections = True Then

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = 1
Else

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = 0
End If

to

If intCurrentMonth Collections = True Then

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue =
"true"
Else

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue =
"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.Up date() in my update function
My SQLDataSource:
-------------------------

<asp:SqlDataSou rce
ID="ds_dashboar d"
runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:DashboardCon n %>"
SelectCommand=" aspx_Get_Custom er_DashboardGra phs"
SelectCommandTy pe="StoredProce dure"
UpdateCommand=" aspx_Update_Cus tomer_Dashboard Graphs"
UpdateCommandTy pe="StoredProce dure"
>
<UpdateParamete rs>
<asp:Paramete r Name="CustomerI D" Type="Int32" />
<asp:Paramete r Name="Budget" Type="Int32" />
<asp:Paramete r Name="CurrentMo nthCollections"
Type="Boolean" />
<asp:Paramete r Name="RevenueBy Month" Type="Boolean"
/>
<asp:Paramete r Name="PDCsCCsMo nthly" Type="Boolean"
/>
<asp:Paramete r Name="RevenueBy Client" Type="Boolean"
/>

</UpdateParameter s>

</asp:SqlDataSour ce>
My GridView:
---------------------

<asp:GridView
ID="gv_dashboar d"
runat="server"
AutoGenerateCol umns="False"
DataSourceID="d s_dashboard"
CellPadding="4"
ForeColor="#333 333"
ShowFooter="Tru e"
GridLines="None "
CssClass="Forma tFont">

<Columns>
<asp:TemplateFi eld HeaderText="Cus t #"
SortExpression= "CustomerID ">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:Label runat="server" id="lblCustomer ID"
Text='<%# Bind("Customer" ) %>' />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Bud get"
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:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Cur rent Month Collections"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_Curren tMonthCollectio ns" />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Rev enue By Month"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_Revenu eByMonth" />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="PDC s & CCS Monthly"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_PDCsCC sMonthly" />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Rev enue By Client"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_Revenu eByClient" />
</ItemTemplate>
</asp:TemplateFie ld>
</Columns>

<FooterStyle BackColor="#5D7 B9D" Font-Bold="True"
ForeColor="Whit e" />
<RowStyle BackColor="#F7F 6F3" ForeColor="#333 333" />
<EditRowStyle BackColor="#DDD DDD" />
<SelectedRowSty le BackColor="#DDD DDD" Font-Bold="True"
ForeColor="#333 333" />
<PagerStyle BackColor="#284 775" ForeColor="Whit e"
HorizontalAlign ="Center" />
<HeaderStyle BackColor="#5D7 B9D" Font-Bold="True"
ForeColor="Whit e" />
<AlternatingRow Style BackColor="Whit e" ForeColor="#284 775" />
</asp:GridView>
My Update Command (Stored Procedure):
--------------------------------------------------

ALTER PROCEDURE [dbo].[aspx_Update_Cus tomer_Dashboard Graphs]

@CustomerID bigint,
@Budget int,
@CurrentMonthCo llections bit,
@RevenueByMonth bit,
@PDCsCCsMonthly bit,
@RevenueByClien t bit

AS
BEGIN

UPDATE dbo.Customer_Da shboardGraphs
SET Budget = @Budget,
CurrentMonthCol lections = @CurrentMonthCo llections,
RevenueByMonth = @RevenueByMonth ,
PDCsCCsMonthly = @PDCsCCsMonthly ,
RevenueByClient = @RevenueByClien t
WHERE Customer_Dashbo ardGraphs.Custo mer = @CustomerID
END
My Table Schema:
-----------------------

CREATE TABLE [dbo].[Customer_Dashbo ardGraphs](
[Customer] [nchar](10) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS NULL,
[DashboardGraphI D] [bit] NULL,
[CurrentMonthCol lections] [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.FormatEx ception: String was not recognized as a
valid Boolean.

Source Error:
Line 53:
ds_dashboard.Up dateParameters( "Budget").Defau ltValue = intBudget
Line 54:
Line 55: ds_dashboard.Up date()
Line 56: End If
Line 57: Next
Source File:
Y:\inetpub\wwwr oot\apex\webapp s\dashboard\das hboard\index.as px.vb
Line: 55
Stack Trace:
------------------

[FormatException : String was not recognized as a valid Boolean.]
System.Boolean. Parse(String value) +2709172
System.String.S ystem.IConverti ble.ToBoolean(I FormatProvider provider)
+12
System.Convert. ChangeType(Obje ct value, TypeCode typeCode,
IFormatProvider provider) +98
System.Web.UI.W ebControls.Para meter.GetValue( Object value, String
defaultValue, TypeCode type, Boolean convertEmptyStr ingToNull, Boolean
ignoreNullableT ypeChanges) +257
System.Web.UI.W ebControls.Para meter.get_Param eterValue() +91
System.Web.UI.W ebControls.Para meterCollection .GetValues(Http Context
context, Control control) +282

System.Web.UI.W ebControls.SqlD ataSourceView.I nitializeParame ters(DbCommand
command, ParameterCollec tion parameters, IDictionary exclusionList) +344
System.Web.UI.W ebControls.SqlD ataSourceView.E xecuteUpdate(ID ictionary
keys, IDictionary values, IDictionary oldValues) +449
System.Web.UI.W ebControls.SqlD ataSourceView.U pdate(IDictiona ry keys,
IDictionary values, IDictionary oldValues) +37
System.Web.UI.W ebControls.SqlD ataSource.Updat e() +42
dashboard._Defa ult.UpdateCusto mer_DashboardGr aphs(Object sender,
EventArgs e) in
Y:\inetpub\wwwr oot\sss\webapps \dashboard\dash board\index.asp x.vb:55
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +96
System.Web.UI.W ebControls.Butt on.RaisePostBac kEvent(String
eventArgument)
+116

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument) +31
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +32
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
+72
System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
+3837
--
dba123
"Karl Seguin [MVP]" wrote:

> which line is the error on?
>
> Karl
>
> --
> http://www.openmymind.net/
>
>
>
> "dba123" <db****@discuss ions.microsoft. com> wrote in message
> news:0F******** *************** ***********@mic rosoft.com...
> > Why am I getting this error for Budget?
> >
> > Error: An exception of type 'System.FormatE xception' 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.EventArg s)
> > For Each gvr As GridViewRow In gv_dashboard.Ro ws

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.Up dateParameters( "CurrentMonthCo llections").Def aultValue =
intCurrentMonth Collections

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****@discuss ions.microsoft. com> wrote in message
news:46******** *************** ***********@mic rosoft.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 intCurrentMonth Collections = True Then

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = 1
Else

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = 0
End If

to

If intCurrentMonth Collections = True Then

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue =
"true"
Else

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue =
"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.Up date() in my update function
My SQLDataSource:
-------------------------

<asp:SqlDataSou rce
ID="ds_dashboar d"
runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:DashboardCon n %>"
SelectCommand=" aspx_Get_Custom er_DashboardGra phs"
SelectCommandTy pe="StoredProce dure"
UpdateCommand=" aspx_Update_Cus tomer_Dashboard Graphs"
UpdateCommandTy pe="StoredProce dure"
>
<UpdateParamete rs>
<asp:Paramete r Name="CustomerI D" Type="Int32" />
<asp:Paramete r Name="Budget" Type="Int32" />
<asp:Paramete r Name="CurrentMo nthCollections"
Type="Boolean" />
<asp:Paramete r Name="RevenueBy Month" Type="Boolean"
/>
<asp:Paramete r Name="PDCsCCsMo nthly" Type="Boolean"
/>
<asp:Paramete r Name="RevenueBy Client" Type="Boolean"
/>

</UpdateParameter s>

</asp:SqlDataSour ce>
My GridView:
---------------------

<asp:GridView
ID="gv_dashboar d"
runat="server"
AutoGenerateCol umns="False"
DataSourceID="d s_dashboard"
CellPadding="4"
ForeColor="#333 333"
ShowFooter="Tru e"
GridLines="None "
CssClass="Forma tFont">

<Columns>
<asp:TemplateFi eld HeaderText="Cus t #"
SortExpression= "CustomerID ">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:Label runat="server" id="lblCustomer ID"
Text='<%# Bind("Customer" ) %>' />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Bud get"
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:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Cur rent Month Collections"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_Curren tMonthCollectio ns" />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Rev enue By Month"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_Revenu eByMonth" />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="PDC s & CCS Monthly"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_PDCsCC sMonthly" />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Rev enue By Client"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_Revenu eByClient" />
</ItemTemplate>
</asp:TemplateFie ld>
</Columns>

<FooterStyle BackColor="#5D7 B9D" Font-Bold="True"
ForeColor="Whit e" />
<RowStyle BackColor="#F7F 6F3" ForeColor="#333 333" />
<EditRowStyle BackColor="#DDD DDD" />
<SelectedRowSty le BackColor="#DDD DDD" Font-Bold="True"
ForeColor="#333 333" />
<PagerStyle BackColor="#284 775" ForeColor="Whit e"
HorizontalAlign ="Center" />
<HeaderStyle BackColor="#5D7 B9D" Font-Bold="True"
ForeColor="Whit e" />
<AlternatingRow Style BackColor="Whit e" ForeColor="#284 775" />
</asp:GridView>
My Update Command (Stored Procedure):
--------------------------------------------------

ALTER PROCEDURE [dbo].[aspx_Update_Cus tomer_Dashboard Graphs]

@CustomerID bigint,
@Budget int,
@CurrentMonthCo llections bit,
@RevenueByMonth bit,
@PDCsCCsMonthly bit,
@RevenueByClien t bit

AS
BEGIN

UPDATE dbo.Customer_Da shboardGraphs
SET Budget = @Budget,
CurrentMonthCol lections = @CurrentMonthCo llections,
RevenueByMonth = @RevenueByMonth ,
PDCsCCsMonthly = @PDCsCCsMonthly ,
RevenueByClient = @RevenueByClien t
WHERE Customer_Dashbo ardGraphs.Custo mer = @CustomerID
END
My Table Schema:
-----------------------

CREATE TABLE [dbo].[Customer_Dashbo ardGraphs](
[Customer] [nchar](10) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS NULL,
[DashboardGraphI D] [bit] NULL,
[CurrentMonthCol lections] [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.FormatEx ception: String was not recognized as a
valid Boolean.

Source Error:
Line 53:
ds_dashboard.Up dateParameters( "Budget").Defau ltValue = intBudget
Line 54:
Line 55: ds_dashboard.Up date()
Line 56: End If
Line 57: Next
Source File:
Y:\inetpub\wwwr oot\apex\webapp s\dashboard\das hboard\index.as px.vb
Line: 55
Stack Trace:
------------------

[FormatException : String was not recognized as a valid Boolean.]
System.Boolean. Parse(String value) +2709172
System.String.S ystem.IConverti ble.ToBoolean(I FormatProvider provider)
+12
System.Convert. ChangeType(Obje ct value, TypeCode typeCode,
IFormatProvider provider) +98
System.Web.UI.W ebControls.Para meter.GetValue( Object value, String
defaultValue, TypeCode type, Boolean convertEmptyStr ingToNull, Boolean
ignoreNullableT ypeChanges) +257
System.Web.UI.W ebControls.Para meter.get_Param eterValue() +91
System.Web.UI.W ebControls.Para meterCollection .GetValues(Http Context
context, Control control) +282

System.Web.UI.W ebControls.SqlD ataSourceView.I nitializeParame ters(DbCommand
command, ParameterCollec tion parameters, IDictionary exclusionList) +344
System.Web.UI.W ebControls.SqlD ataSourceView.E xecuteUpdate(ID ictionary
keys, IDictionary values, IDictionary oldValues) +449
System.Web.UI.W ebControls.SqlD ataSourceView.U pdate(IDictiona ry keys,
IDictionary values, IDictionary oldValues) +37
System.Web.UI.W ebControls.SqlD ataSource.Updat e() +42
dashboard._Defa ult.UpdateCusto mer_DashboardGr aphs(Object sender,
EventArgs e) in
Y:\inetpub\wwwr oot\sss\webapps \dashboard\dash board\index.asp x.vb:55
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +96
System.Web.UI.W ebControls.Butt on.RaisePostBac kEvent(String
eventArgument)
+116

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument) +31
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +32
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
+72
System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
+3837
--
dba123
"Karl Seguin [MVP]" wrote:

> which line is the error on?
>
> Karl
>
> --
> http://www.openmymind.net/
>
>
>
> "dba123" <db****@discuss ions.microsoft. com> wrote in message
> news:0F******** *************** ***********@mic rosoft.com...
> > Why am I getting this error for Budget?
> >
> > Error: An exception of type 'System.FormatE xception' 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.EventArg s)
> > For Each gvr As GridViewRow In gv_dashboard.Ro ws

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(CurrentM onthCollections , false) as
CurrentMonthCol lections for selecting a default value, or check for null
before binding, you can do that inline via:

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

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"dba123" <db****@discuss ions.microsoft. com> wrote in message
news:57******** *************** ***********@mic rosoft.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_Curren tMonthCollectio ns" Checked='<%#
Bind("CurrentMo nthCollections" ) %>'/>
</ItemTemplate>
</asp:TemplateFie ld>

Error: An exception of type 'System.Invalid CastException' occurred in
Microsoft.Visua lBasic.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.FormatE xception' 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.EventArg s)
For Each gvr As GridViewRow In gv_dashboard.Ro ws
If gvr.RowType = DataControlRowT ype.DataRow Then

'//--IDs

Dim intCustomerID As String =
CType(gvr.FindC ontrol("lblCust omerID"), Label).Text.Tri m()

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

'//--Checkboxes
Dim intCurrentMonth Collections As Boolean =
CType(gvr.FindC ontrol("chbx_Cu rrentMonthColle ctions"), CheckBox).Check ed
Dim intRevenueByMon th As Boolean =
CType(gvr.FindC ontrol("chbx_Re venueByMonth"), CheckBox).Check ed
Dim intPDCsCCsMonth ly As Boolean =
CType(gvr.FindC ontrol("chbx_PD CsCCsMonthly"), CheckBox).Check ed
Dim intRevenueByCli ent As Boolean =
CType(gvr.FindC ontrol("chbx_Re venueByClient") , CheckBox).Check ed

'//--Assign UpdateParameter s
If intCurrentMonth Collections = True Then

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = 1
Else

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = 0
End If
...

ds_dashboard.Up dateParameters( "Budget").Defau ltValue =
intBudget

ds_dashboard.Up date()
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:SqlDataSou rce
ID="ds_dashboar d"
runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:DashboardCon n %>"
SelectCommand=" aspx_Get_Custom er_DashboardGra phs"
SelectCommandTy pe="StoredProce dure"
UpdateCommand=" aspx_Update_Cus tomer_Dashboard Graphs"
UpdateCommandTy pe="StoredProce dure"
<UpdateParamete rs>
<asp:Paramete r Name="CustomerI D" Type="Int32" />
<asp:Paramete r Name="Budget" Type="Int32" />
<asp:Paramete r Name="CurrentMo nthCollections"
Type="Boolean" />
<asp:Paramete r Name="RevenueBy Month" Type="Boolean" />
<asp:Paramete r Name="PDCsCCsMo nthly" Type="Boolean" />
<asp:Paramete r Name="RevenueBy Client" Type="Boolean" />

</UpdateParameter s>

</asp:SqlDataSour ce>
<asp:GridView
ID="gv_dashboar d"
runat="server"
AutoGenerateCol umns="False"
DataSourceID="d s_dashboard"
CellPadding="4"
ForeColor="#333 333"
ShowFooter="Tru e"
GridLines="None "
CssClass="Forma tFont">

<Columns>
<asp:TemplateFi eld HeaderText="Cus t #"
SortExpression= "CustomerID ">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:Label runat="server" id="lblCustomer ID"
Text='<%# Bind("Customer" ) %>' />
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Bud get" 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:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Cur rent Month Collections"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_Curren tMonthCollectio ns" Checked='<%#
Bind("CurrentMo nthCollections" ) %>'/>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Rev enue By Month"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_Revenu eByMonth" Checked='<%# Bind("RevenueBy Month") %>'/>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="PDC s & CCS Monthly"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_PDCsCC sMonthly" Checked='<%# Bind("PDCsCCsMo nthly") %>'/>
</ItemTemplate>
</asp:TemplateFie ld>
<asp:TemplateFi eld HeaderText="Rev enue By Client"
SortExpression= "Name" ItemStyle-HorizontalAlign ="Center">
<HeaderStyle HorizontalAlign ="center"></HeaderStyle>
<ItemTemplate >
<asp:checkbox runat="server"
Id="chbx_Revenu eByClient" Checked='<%# Bind("RevenueBy Client") %>'/>
</ItemTemplate>
</asp:TemplateFie ld>
</Columns>

<FooterStyle BackColor="#5D7 B9D" Font-Bold="True"
ForeColor="Whit e" />
<RowStyle BackColor="#F7F 6F3" ForeColor="#333 333" />
<EditRowStyle BackColor="#DDD DDD" />
<SelectedRowSty le BackColor="#DDD DDD" Font-Bold="True"
ForeColor="#333 333" />
<PagerStyle BackColor="#284 775" ForeColor="Whit e"
HorizontalAlign ="Center" />
<HeaderStyle BackColor="#5D7 B9D" Font-Bold="True"
ForeColor="Whit e" />
<AlternatingRow Style BackColor="Whit e" ForeColor="#284 775" />

</asp:GridView>
Stored proc behind the Select Command

ALTER PROCEDURE [dbo].[aspx_Get_Custom er_DashboardGra phs]

AS
BEGIN

SELECT Customer,
ISNULL(Budget, 0) as Budget,
ISNULL(CurrentM onthCollections , 0) as CurrentMonthCol lections,
ISNULL(RevenueB yMonth, 0)as RevenueByMonth,
ISNULL(PDCsCCsM onthly, 0) as PDCsCCsMonthly,
ISNULL(RevenueB yClient, 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_Cus tomer_Dashboard Graphs]

@CustomerID bigint,
@Budget bigint,
@CurrentMonthCo llections bit,
@RevenueByMonth bit,
@PDCsCCsMonthly bit,
@RevenueByClien t bit

AS
BEGIN

UPDATE dbo.Customer_Da shboardGraphs
SET Budget = @Budget,
CurrentMonthCol lections = @CurrentMonthCo llections,
RevenueByMonth = @RevenueByMonth ,
PDCsCCsMonthly = @PDCsCCsMonthly ,
RevenueByClient = @RevenueByClien t
WHERE Customer_Dashbo ardGraphs.Custo mer = @CustomerID
END
------------------------------------- Code Behind
-------------------------------------------------------------

Public Sub UpdateCustomer_ DashboardGraphs (ByVal sender As Object, ByVal
e As System.EventArg s)
For Each gvr As GridViewRow In gv_dashboard.Ro ws
If gvr.RowType = DataControlRowT ype.DataRow Then

'//--IDs

Dim intCustomerID As String =
CType(gvr.FindC ontrol("lblCust omerID"), Label).Text.Tri m()

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

'//--Checkboxes
Dim bolCurrentMonth Collections As Boolean =
CType(gvr.FindC ontrol("chbx_Cu rrentMonthColle ctions"), CheckBox).Check ed
Dim bolRevenueByMon th As Boolean =
CType(gvr.FindC ontrol("chbx_Re venueByMonth"), CheckBox).Check ed
Dim bolPDCsCCsMonth ly As Boolean =
CType(gvr.FindC ontrol("chbx_PD CsCCsMonthly"), CheckBox).Check ed
Dim bolRevenueByCli ent As Boolean =
CType(gvr.FindC ontrol("chbx_Re venueByClient") , CheckBox).Check ed

'//--Assign UpdateParameter s
If bolCurrentMonth Collections = True Then
ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = True
Else

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = False
End If
If bolRevenueByMon th = True Then

ds_dashboard.Up dateParameters( "RevenueByMonth ").DefaultV alue = True
Else

ds_dashboard.Up dateParameters( "RevenueByMonth ").DefaultV alue = False
End If
If bolPDCsCCsMonth ly = True Then

ds_dashboard.Up dateParameters( "PDCsCCsMonthly ").DefaultV alue = True
Else

ds_dashboard.Up dateParameters( "PDCsCCsMonthly ").DefaultV alue = False
End If
If bolRevenueByCli ent = True Then

ds_dashboard.Up dateParameters( "RevenueByClien t").DefaultValu e = True
Else

ds_dashboard.Up dateParameters( "RevenueByClien t").DefaultValu e = False
End If

ds_dashboard.Up dateParameters( "Budget").Defau ltValue =
intBudget

ds_dashboard.Up date()
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(CurrentM onthCollections , false) as
CurrentMonthCol lections for selecting a default value, or check for null
before binding, you can do that inline via:

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

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"dba123" <db****@discuss ions.microsoft. com> wrote in message
news:57******** *************** ***********@mic rosoft.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_Curren tMonthCollectio ns" Checked='<%#
Bind("CurrentMo nthCollections" ) %>'/>
</ItemTemplate>
</asp:TemplateFie ld>

Error: An exception of type 'System.Invalid CastException' occurred in
Microsoft.Visua lBasic.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.FormatE xception' 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.EventArg s)
For Each gvr As GridViewRow In gv_dashboard.Ro ws
If gvr.RowType = DataControlRowT ype.DataRow Then

'//--IDs

Dim intCustomerID As String =
CType(gvr.FindC ontrol("lblCust omerID"), Label).Text.Tri m()

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

'//--Checkboxes
Dim intCurrentMonth Collections As Boolean =
CType(gvr.FindC ontrol("chbx_Cu rrentMonthColle ctions"), CheckBox).Check ed
Dim intRevenueByMon th As Boolean =
CType(gvr.FindC ontrol("chbx_Re venueByMonth"), CheckBox).Check ed
Dim intPDCsCCsMonth ly As Boolean =
CType(gvr.FindC ontrol("chbx_PD CsCCsMonthly"), CheckBox).Check ed
Dim intRevenueByCli ent As Boolean =
CType(gvr.FindC ontrol("chbx_Re venueByClient") , CheckBox).Check ed

'//--Assign UpdateParameter s
If intCurrentMonth Collections = True Then

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = 1
Else

ds_dashboard.Up dateParameters( "CurrentMonthCo llections").Def aultValue = 0
End If
...

ds_dashboard.Up dateParameters( "Budget").Defau ltValue =
intBudget

ds_dashboard.Up date()
End If
Next
End Sub
--
dba123


Apr 25 '06 #10

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

Similar topics

6
6659
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
19446
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: return 'False'
1
4138
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 then I thought it must be available in the .net framework XML classes somewhere. Is it?
11
33332
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 code: Dim blnDate_Valid As Boolean = True Dim x As String = "Hello"
5
2955
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, RegexOptions.IgnoreCase | RegexOptions.Multiline); if (re.Matches(color1).Count 0)
2
2027
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) == true){ // do something... }
3
3967
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) debugging instead of this dialog box. ************** Exception Text ************** System.FormatException: String was not recognized as a valid Boolean.
0
9781
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10836
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7960
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7114
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5791
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5982
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3230
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.