Showing posts with label user. Show all posts
Showing posts with label user. Show all posts

Saturday, March 31, 2012

String Stripping

Hi,

I am trying to create a page that will check user input against a value in database. This page will have a text box for user to enter serial #.
Serial # length is variable but last 3 digit is always number.
For examples:
W04051234-PAY001 in this example code is 1234-PAY
W05051234-PAT002 in this example code is 1234-PAT

A12056040-G001 in this example code is 6040-G
B11056080-SU001 in this example code is 6080-s

Which is the best approach to extract CODE from user input?

Any help will be appriciated.

Thank

TekinUse the Regular Expression class, RegExp with a regular expression that looks for:
4 digits (or is it 3?) followed by
dash
followed by 1 or letters

That expression is:
\d{4}\-[A-Za-z]+
Actually,

I would like to Trancate first 5 digits and last 3 digits.

For examples:
W04051234-PAY001 in this example code is 1234-PAY
If you are attempting to strip a specific group of characters, the String class has numerous useful methods. I encourage you to read about the String class in the .net docs. I think the SubString() and Length() methods will be useful.

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_CurrentMonthCollections"), CheckBox).Checked
Dim intRevenueByMonth As Boolean =
CType(gvr.FindControl("chbx_RevenueByMonth"), CheckBox).Checked
Dim intPDCsCCsMonthly As Boolean =
CType(gvr.FindControl("chbx_PDCsCCsMonthly"), CheckBox).Checked
Dim intRevenueByClient As Boolean =
CType(gvr.FindControl("chbx_RevenueByClient"), CheckBox).Checked

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

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

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

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

ds_dashboard.Update()
End If
Next
End Sub
--
dba123which line is the error on?

Karl

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

"dba123" <dba123@.discussions.microsoft.com> wrote in message
news:0FCAE9F2-E68A-4794-9A68-BAF5877BA533@.microsoft.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_CurrentMonthCollections"), CheckBox).Checked
> Dim intRevenueByMonth As Boolean =
> CType(gvr.FindControl("chbx_RevenueByMonth"), CheckBox).Checked
> Dim intPDCsCCsMonthly As Boolean =
> CType(gvr.FindControl("chbx_PDCsCCsMonthly"), CheckBox).Checked
> Dim intRevenueByClient As Boolean =
> CType(gvr.FindControl("chbx_RevenueByClient"), CheckBox).Checked
> '//--Assign UpdateParameters
> If intCurrentMonthCollections = True Then
> ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 1
> Else
> ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 0
> End If
> ...
> ds_dashboard.UpdateParameters("Budget").DefaultValue =
> intBudget
> ds_dashboard.Update()
> End If
> Next
> End Sub
> --
> dba123
String was not recognized as a valid Boolean

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

My SQLDataSource:
--------

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

<asp:GridView
ID="gv_dashboard"
runat="server"
AutoGenerateColumns="False"
DataSourceID="ds_dashboard"
CellPadding="4"
ForeColor="#333333"
ShowFooter="True"
GridLines="None"
CssClass="FormatFont"
<Columns>
<asp:TemplateField HeaderText="Cust #"
SortExpression="CustomerID">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:Label runat="server" id="lblCustomerID"
Text='<%# Bind("Customer") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Budget" SortExpression="Name"
ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
<ItemTemplate>
<asp:TextBox width="55px" MaxLength="10"
ID="txtBudget" Text='<%# Bind("Budget") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Current Month Collections"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_CurrentMonthCollections" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Revenue By Month"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_RevenueByMonth" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="PDCs & CCS Monthly"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_PDCsCCsMonthly" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Revenue By Client"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_RevenueByClient" />
</ItemTemplate>
</asp:TemplateField>
</Columns
<FooterStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#DDDDDD" />
<SelectedRowStyle BackColor="#DDDDDD" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView
My Update Command (Stored Procedure):
----------------

ALTER PROCEDURE [dbo].[aspx_Update_Customer_DashboardGraphs]

@.CustomerIDbigint,
@.Budgetint,
@.CurrentMonthCollectionsbit,
@.RevenueByMonthbit,
@.PDCsCCsMonthlybit,
@.RevenueByClientbit

AS
BEGIN

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

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

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

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

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

Source Error:

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

Source File:
Y:\inetpub\wwwroot\apex\webapps\dashboard\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" <dba123@.discussions.microsoft.com> wrote in message
> news:0FCAE9F2-E68A-4794-9A68-BAF5877BA533@.microsoft.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_CurrentMonthCollections"), CheckBox).Checked
> > Dim intRevenueByMonth As Boolean =
> > CType(gvr.FindControl("chbx_RevenueByMonth"), CheckBox).Checked
> > Dim intPDCsCCsMonthly As Boolean =
> > CType(gvr.FindControl("chbx_PDCsCCsMonthly"), CheckBox).Checked
> > Dim intRevenueByClient As Boolean =
> > CType(gvr.FindControl("chbx_RevenueByClient"), CheckBox).Checked
> > '//--Assign UpdateParameters
> > If intCurrentMonthCollections = True Then
> > ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 1
> > Else
> > ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 0
> > End If
> > ...
> > ds_dashboard.UpdateParameters("Budget").DefaultValue =
> > intBudget
> > ds_dashboard.Update()
> > End If
> > Next
> > End Sub
> > --
> > dba123
>
Ok, I changed these since SQL Server bit is expecting true or false, not 1 or
zero...that would be for an integer db field:

If intCurrentMonthCollections = True Then

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

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

to

If intCurrentMonthCollections = True Then

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

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

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

--
dba123

"dba123" 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_DashboardGraphs"
> UpdateCommandType="StoredProcedure"
> >
> <UpdateParameters>
> <asp:Parameter Name="CustomerID" Type="Int32" />
> <asp:Parameter Name="Budget" Type="Int32" />
> <asp:Parameter Name="CurrentMonthCollections"
> Type="Boolean" />
> <asp:Parameter Name="RevenueByMonth" Type="Boolean" />
> <asp:Parameter Name="PDCsCCsMonthly" Type="Boolean" />
> <asp:Parameter Name="RevenueByClient" Type="Boolean" />
> </UpdateParameters>
> </asp:SqlDataSource>
>
> My GridView:
> -------
> <asp:GridView
> ID="gv_dashboard"
> runat="server"
> AutoGenerateColumns="False"
> DataSourceID="ds_dashboard"
> CellPadding="4"
> ForeColor="#333333"
> ShowFooter="True"
> GridLines="None"
> CssClass="FormatFont">
> <Columns>
> <asp:TemplateField HeaderText="Cust #"
> SortExpression="CustomerID">
> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
> <ItemTemplate>
> <asp:Label runat="server" id="lblCustomerID"
> Text='<%# Bind("Customer") %>' />
> </ItemTemplate>
> </asp:TemplateField>
> <asp:TemplateField HeaderText="Budget" SortExpression="Name"
> ItemStyle-HorizontalAlign="Center">
> <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
> <ItemTemplate>
> <asp:TextBox width="55px" MaxLength="10"
> ID="txtBudget" Text='<%# Bind("Budget") %>' runat="server" />
> </ItemTemplate>
> </asp:TemplateField>
> <asp:TemplateField HeaderText="Current Month Collections"
> SortExpression="Name" ItemStyle-HorizontalAlign="Center">
> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
> <ItemTemplate>
> <asp:checkbox runat="server"
> Id="chbx_CurrentMonthCollections" />
> </ItemTemplate>
> </asp:TemplateField>
> <asp:TemplateField HeaderText="Revenue By Month"
> SortExpression="Name" ItemStyle-HorizontalAlign="Center">
> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
> <ItemTemplate>
> <asp:checkbox runat="server"
> Id="chbx_RevenueByMonth" />
> </ItemTemplate>
> </asp:TemplateField>
> <asp:TemplateField HeaderText="PDCs & CCS Monthly"
> SortExpression="Name" ItemStyle-HorizontalAlign="Center">
> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
> <ItemTemplate>
> <asp:checkbox runat="server"
> Id="chbx_PDCsCCsMonthly" />
> </ItemTemplate>
> </asp:TemplateField>
> <asp:TemplateField HeaderText="Revenue By Client"
> SortExpression="Name" ItemStyle-HorizontalAlign="Center">
> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
> <ItemTemplate>
> <asp:checkbox runat="server"
> Id="chbx_RevenueByClient" />
> </ItemTemplate>
> </asp:TemplateField>
> </Columns>
> <FooterStyle BackColor="#5D7B9D" Font-Bold="True"
> ForeColor="White" />
> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
> <EditRowStyle BackColor="#DDDDDD" />
> <SelectedRowStyle BackColor="#DDDDDD" Font-Bold="True"
> ForeColor="#333333" />
> <PagerStyle BackColor="#284775" ForeColor="White"
> HorizontalAlign="Center" />
> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
> ForeColor="White" />
> <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
> </asp:GridView>
>
> My Update Command (Stored Procedure):
> ----------------
> ALTER PROCEDURE [dbo].[aspx_Update_Customer_DashboardGraphs]
> @.CustomerIDbigint,
> @.Budgetint,
> @.CurrentMonthCollectionsbit,
> @.RevenueByMonthbit,
> @.PDCsCCsMonthlybit,
> @.RevenueByClientbit
> AS
> BEGIN
> UPDATE dbo.Customer_DashboardGraphs
> SET Budget = @.Budget,
> CurrentMonthCollections = @.CurrentMonthCollections,
> RevenueByMonth = @.RevenueByMonth,
> PDCsCCsMonthly = @.PDCsCCsMonthly,
> RevenueByClient = @.RevenueByClient
> WHERE Customer_DashboardGraphs.Customer = @.CustomerID
> END
>
> My Table Schema:
> --------
> CREATE TABLE [dbo].[Customer_DashboardGraphs](
> [Customer] [nchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
> [DashboardGraphID] [bit] NULL,
> [CurrentMonthCollections] [bit] NULL,
> [RevenueByMonth] [bit] NULL,
> [PDCsCCsMonthly] [bit] NULL,
> [RevenueByClient] [bit] NULL,
> [Budget] [int] NULL
> ) ON [PRIMARY]
> Stack Trace:
> String was not recognized as a valid Boolean.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information about
> the error and where it originated in the code.
> Exception Details: System.FormatException: String was not recognized as a
> valid Boolean.
> Source Error:
>
> Line 53:
> ds_dashboard.UpdateParameters("Budget").DefaultValue = intBudget
> Line 54:
> Line 55: ds_dashboard.Update()
> Line 56: End If
> Line 57: Next
>
> Source File:
> Y:\inetpub\wwwroot\apex\webapps\dashboard\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" <dba123@.discussions.microsoft.com> wrote in message
> > news:0FCAE9F2-E68A-4794-9A68-BAF5877BA533@.microsoft.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_CurrentMonthCollections"), CheckBox).Checked
> > > Dim intRevenueByMonth As Boolean =
> > > CType(gvr.FindControl("chbx_RevenueByMonth"), CheckBox).Checked
> > > Dim intPDCsCCsMonthly As Boolean =
> > > CType(gvr.FindControl("chbx_PDCsCCsMonthly"), CheckBox).Checked
> > > Dim intRevenueByClient As Boolean =
> > > CType(gvr.FindControl("chbx_RevenueByClient"), CheckBox).Checked
> > > > '//--Assign UpdateParameters
> > > If intCurrentMonthCollections = True Then
> > > > ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 1
> > > Else
> > > > ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 0
> > > End If
> > > ...
> > > > ds_dashboard.UpdateParameters("Budget").DefaultValue =
> > > intBudget
> > > > ds_dashboard.Update()
> > > End If
> > > Next
> > > End Sub
> > > --
> > > dba123
Why don't you just set it to true/false instead of "true"/"fale"

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

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

Karl

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

"dba123" <dba123@.discussions.microsoft.com> wrote in message
news:460D12E2-2F3F-446F-BBA3-CA80CDAE09F1@.microsoft.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("CurrentMonthCollections").DefaultValue = 1
> Else
> ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 0
> End If
> to
> If intCurrentMonthCollections = True Then
> ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue =
> "true"
> Else
> ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue =
> "false"
> End If
> The error goes away but it's still not updating those bit fields in my
> table
>
> --
> dba123
>
> "dba123" 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_DashboardGraphs"
>> UpdateCommandType="StoredProcedure"
>> >
>> <UpdateParameters>
>> <asp:Parameter Name="CustomerID" Type="Int32" />
>> <asp:Parameter Name="Budget" Type="Int32" />
>> <asp:Parameter Name="CurrentMonthCollections"
>> Type="Boolean" />
>> <asp:Parameter Name="RevenueByMonth" Type="Boolean"
>> />
>> <asp:Parameter Name="PDCsCCsMonthly" Type="Boolean"
>> />
>> <asp:Parameter Name="RevenueByClient" Type="Boolean"
>> />
>>
>> </UpdateParameters>
>>
>> </asp:SqlDataSource>
>>
>>
>> My GridView:
>> -------
>>
>> <asp:GridView
>> ID="gv_dashboard"
>> runat="server"
>> AutoGenerateColumns="False"
>> DataSourceID="ds_dashboard"
>> CellPadding="4"
>> ForeColor="#333333"
>> ShowFooter="True"
>> GridLines="None"
>> CssClass="FormatFont">
>>
>> <Columns>
>> <asp:TemplateField HeaderText="Cust #"
>> SortExpression="CustomerID">
>> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
>> <ItemTemplate>
>> <asp:Label runat="server" id="lblCustomerID"
>> Text='<%# Bind("Customer") %>' />
>> </ItemTemplate>
>> </asp:TemplateField>
>> <asp:TemplateField HeaderText="Budget"
>> SortExpression="Name"
>> ItemStyle-HorizontalAlign="Center">
>> <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
>> <ItemTemplate>
>> <asp:TextBox width="55px" MaxLength="10"
>> ID="txtBudget" Text='<%# Bind("Budget") %>' runat="server" />
>> </ItemTemplate>
>> </asp:TemplateField>
>> <asp:TemplateField HeaderText="Current Month Collections"
>> SortExpression="Name" ItemStyle-HorizontalAlign="Center">
>> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
>> <ItemTemplate>
>> <asp:checkbox runat="server"
>> Id="chbx_CurrentMonthCollections" />
>> </ItemTemplate>
>> </asp:TemplateField>
>> <asp:TemplateField HeaderText="Revenue By Month"
>> SortExpression="Name" ItemStyle-HorizontalAlign="Center">
>> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
>> <ItemTemplate>
>> <asp:checkbox runat="server"
>> Id="chbx_RevenueByMonth" />
>> </ItemTemplate>
>> </asp:TemplateField>
>> <asp:TemplateField HeaderText="PDCs & CCS Monthly"
>> SortExpression="Name" ItemStyle-HorizontalAlign="Center">
>> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
>> <ItemTemplate>
>> <asp:checkbox runat="server"
>> Id="chbx_PDCsCCsMonthly" />
>> </ItemTemplate>
>> </asp:TemplateField>
>> <asp:TemplateField HeaderText="Revenue By Client"
>> SortExpression="Name" ItemStyle-HorizontalAlign="Center">
>> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
>> <ItemTemplate>
>> <asp:checkbox runat="server"
>> Id="chbx_RevenueByClient" />
>> </ItemTemplate>
>> </asp:TemplateField>
>> </Columns>
>>
>> <FooterStyle BackColor="#5D7B9D" Font-Bold="True"
>> ForeColor="White" />
>> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
>> <EditRowStyle BackColor="#DDDDDD" />
>> <SelectedRowStyle BackColor="#DDDDDD" Font-Bold="True"
>> ForeColor="#333333" />
>> <PagerStyle BackColor="#284775" ForeColor="White"
>> HorizontalAlign="Center" />
>> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
>> ForeColor="White" />
>> <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
>> </asp:GridView>
>>
>>
>> My Update Command (Stored Procedure):
>> ----------------
>>
>> ALTER PROCEDURE [dbo].[aspx_Update_Customer_DashboardGraphs]
>>
>> @.CustomerID bigint,
>> @.Budget int,
>> @.CurrentMonthCollections bit,
>> @.RevenueByMonth bit,
>> @.PDCsCCsMonthly bit,
>> @.RevenueByClient bit
>>
>> AS
>> BEGIN
>>
>> UPDATE dbo.Customer_DashboardGraphs
>> SET Budget = @.Budget,
>> CurrentMonthCollections = @.CurrentMonthCollections,
>> RevenueByMonth = @.RevenueByMonth,
>> PDCsCCsMonthly = @.PDCsCCsMonthly,
>> RevenueByClient = @.RevenueByClient
>> WHERE Customer_DashboardGraphs.Customer = @.CustomerID
>> END
>>
>>
>> My Table Schema:
>> --------
>>
>> CREATE TABLE [dbo].[Customer_DashboardGraphs](
>> [Customer] [nchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
>> [DashboardGraphID] [bit] NULL,
>> [CurrentMonthCollections] [bit] NULL,
>> [RevenueByMonth] [bit] NULL,
>> [PDCsCCsMonthly] [bit] NULL,
>> [RevenueByClient] [bit] NULL,
>> [Budget] [int] NULL
>> ) ON [PRIMARY]
>> Stack Trace:
>>
>> String was not recognized as a valid Boolean.
>> Description: An unhandled exception occurred during the execution of the
>> current web request. Please review the stack trace for more information
>> about
>> the error and where it originated in the code.
>>
>> Exception Details: System.FormatException: String was not recognized as a
>> valid Boolean.
>>
>> Source Error:
>>
>>
>> Line 53:
>> ds_dashboard.UpdateParameters("Budget").DefaultValue = intBudget
>> Line 54:
>> Line 55: ds_dashboard.Update()
>> Line 56: End If
>> Line 57: Next
>>
>>
>> Source File:
>> Y:\inetpub\wwwroot\apex\webapps\dashboard\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" <dba123@.discussions.microsoft.com> wrote in message
>> > news:0FCAE9F2-E68A-4794-9A68-BAF5877BA533@.microsoft.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_CurrentMonthCollections"),
>> > > CheckBox).Checked
>> > > Dim intRevenueByMonth As Boolean =
>> > > CType(gvr.FindControl("chbx_RevenueByMonth"), CheckBox).Checked
>> > > Dim intPDCsCCsMonthly As Boolean =
>> > > CType(gvr.FindControl("chbx_PDCsCCsMonthly"), CheckBox).Checked
>> > > Dim intRevenueByClient As Boolean =
>> > > CType(gvr.FindControl("chbx_RevenueByClient"), CheckBox).Checked
>> >> > > '//--Assign UpdateParameters
>> > > If intCurrentMonthCollections = True Then
>> >> > > ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue
>> > > = 1
>> > > Else
>> >> > > ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue
>> > > = 0
>> > > End If
>> > > ...
>> >> > > ds_dashboard.UpdateParameters("Budget").DefaultValue =
>> > > intBudget
>> >> > > ds_dashboard.Update()
>> > > End If
>> > > Next
>> > > End Sub
>> > > --
>> > > dba123
>>>
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_CurrentMonthCollections"), CheckBox).Checked
> Dim intRevenueByMonth As Boolean =
> CType(gvr.FindControl("chbx_RevenueByMonth"), CheckBox).Checked
> Dim intPDCsCCsMonthly As Boolean =
> CType(gvr.FindControl("chbx_PDCsCCsMonthly"), CheckBox).Checked
> Dim intRevenueByClient As Boolean =
> CType(gvr.FindControl("chbx_RevenueByClient"), CheckBox).Checked
> '//--Assign UpdateParameters
> If intCurrentMonthCollections = True Then
> ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 1
> Else
> ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 0
> End If
> ...
> ds_dashboard.UpdateParameters("Budget").DefaultValue =
> intBudget
> ds_dashboard.Update()
> End If
> Next
> End Sub
> --
> dba123
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("CurrentMonthCollections").DefaultValue =
> intCurrentMonthCollections
> and why is that var prefixed with "int" if it's a bool? Prefixing isn't
> really used much anymore anyways..
> Karl
> --
> http://www.openmymind.net/
> http://www.fuelindustries.com/
>
> "dba123" <dba123@.discussions.microsoft.com> wrote in message
> news:460D12E2-2F3F-446F-BBA3-CA80CDAE09F1@.microsoft.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("CurrentMonthCollections").DefaultValue = 1
> > Else
> > ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 0
> > End If
> > to
> > If intCurrentMonthCollections = True Then
> > ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue =
> > "true"
> > Else
> > ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue =
> > "false"
> > End If
> > The error goes away but it's still not updating those bit fields in my
> > table
> > --
> > dba123
> > "dba123" 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_DashboardGraphs"
> >> UpdateCommandType="StoredProcedure"
> >> >
> >> <UpdateParameters>
> >> <asp:Parameter Name="CustomerID" Type="Int32" />
> >> <asp:Parameter Name="Budget" Type="Int32" />
> >> <asp:Parameter Name="CurrentMonthCollections"
> >> Type="Boolean" />
> >> <asp:Parameter Name="RevenueByMonth" Type="Boolean"
> >> />
> >> <asp:Parameter Name="PDCsCCsMonthly" Type="Boolean"
> >> />
> >> <asp:Parameter Name="RevenueByClient" Type="Boolean"
> >> />
> >>
> >> </UpdateParameters>
> >>
> >> </asp:SqlDataSource>
> >>
> >>
> >> My GridView:
> >> -------
> >>
> >> <asp:GridView
> >> ID="gv_dashboard"
> >> runat="server"
> >> AutoGenerateColumns="False"
> >> DataSourceID="ds_dashboard"
> >> CellPadding="4"
> >> ForeColor="#333333"
> >> ShowFooter="True"
> >> GridLines="None"
> >> CssClass="FormatFont">
> >>
> >> <Columns>
> >> <asp:TemplateField HeaderText="Cust #"
> >> SortExpression="CustomerID">
> >> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
> >> <ItemTemplate>
> >> <asp:Label runat="server" id="lblCustomerID"
> >> Text='<%# Bind("Customer") %>' />
> >> </ItemTemplate>
> >> </asp:TemplateField>
> >> <asp:TemplateField HeaderText="Budget"
> >> SortExpression="Name"
> >> ItemStyle-HorizontalAlign="Center">
> >> <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
> >> <ItemTemplate>
> >> <asp:TextBox width="55px" MaxLength="10"
> >> ID="txtBudget" Text='<%# Bind("Budget") %>' runat="server" />
> >> </ItemTemplate>
> >> </asp:TemplateField>
> >> <asp:TemplateField HeaderText="Current Month Collections"
> >> SortExpression="Name" ItemStyle-HorizontalAlign="Center">
> >> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
> >> <ItemTemplate>
> >> <asp:checkbox runat="server"
> >> Id="chbx_CurrentMonthCollections" />
> >> </ItemTemplate>
> >> </asp:TemplateField>
> >> <asp:TemplateField HeaderText="Revenue By Month"
> >> SortExpression="Name" ItemStyle-HorizontalAlign="Center">
> >> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
> >> <ItemTemplate>
> >> <asp:checkbox runat="server"
> >> Id="chbx_RevenueByMonth" />
> >> </ItemTemplate>
> >> </asp:TemplateField>
> >> <asp:TemplateField HeaderText="PDCs & CCS Monthly"
> >> SortExpression="Name" ItemStyle-HorizontalAlign="Center">
> >> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
> >> <ItemTemplate>
> >> <asp:checkbox runat="server"
> >> Id="chbx_PDCsCCsMonthly" />
> >> </ItemTemplate>
> >> </asp:TemplateField>
> >> <asp:TemplateField HeaderText="Revenue By Client"
> >> SortExpression="Name" ItemStyle-HorizontalAlign="Center">
> >> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
> >> <ItemTemplate>
> >> <asp:checkbox runat="server"
> >> Id="chbx_RevenueByClient" />
> >> </ItemTemplate>
> >> </asp:TemplateField>
> >> </Columns>
> >>
> >> <FooterStyle BackColor="#5D7B9D" Font-Bold="True"
> >> ForeColor="White" />
> >> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
> >> <EditRowStyle BackColor="#DDDDDD" />
> >> <SelectedRowStyle BackColor="#DDDDDD" Font-Bold="True"
> >> ForeColor="#333333" />
> >> <PagerStyle BackColor="#284775" ForeColor="White"
> >> HorizontalAlign="Center" />
> >> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
> >> ForeColor="White" />
> >> <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
> >> </asp:GridView>
> >>
> >>
> >> My Update Command (Stored Procedure):
> >> ----------------
> >>
> >> ALTER PROCEDURE [dbo].[aspx_Update_Customer_DashboardGraphs]
> >>
> >> @.CustomerID bigint,
> >> @.Budget int,
> >> @.CurrentMonthCollections bit,
> >> @.RevenueByMonth bit,
> >> @.PDCsCCsMonthly bit,
> >> @.RevenueByClient bit
> >>
> >> AS
> >> BEGIN
> >>
> >> UPDATE dbo.Customer_DashboardGraphs
> >> SET Budget = @.Budget,
> >> CurrentMonthCollections = @.CurrentMonthCollections,
> >> RevenueByMonth = @.RevenueByMonth,
> >> PDCsCCsMonthly = @.PDCsCCsMonthly,
> >> RevenueByClient = @.RevenueByClient
> >> WHERE Customer_DashboardGraphs.Customer = @.CustomerID
> >> END
> >>
> >>
> >> My Table Schema:
> >> --------
> >>
> >> CREATE TABLE [dbo].[Customer_DashboardGraphs](
> >> [Customer] [nchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
> >> [DashboardGraphID] [bit] NULL,
> >> [CurrentMonthCollections] [bit] NULL,
> >> [RevenueByMonth] [bit] NULL,
> >> [PDCsCCsMonthly] [bit] NULL,
> >> [RevenueByClient] [bit] NULL,
> >> [Budget] [int] NULL
> >> ) ON [PRIMARY]
> >> Stack Trace:
> >>
> >> String was not recognized as a valid Boolean.
> >> Description: An unhandled exception occurred during the execution of the
> >> current web request. Please review the stack trace for more information
> >> about
> >> the error and where it originated in the code.
> >>
> >> Exception Details: System.FormatException: String was not recognized as a
> >> valid Boolean.
> >>
> >> Source Error:
> >>
> >>
> >> Line 53:
> >> ds_dashboard.UpdateParameters("Budget").DefaultValue = intBudget
> >> Line 54:
> >> Line 55: ds_dashboard.Update()
> >> Line 56: End If
> >> Line 57: Next
> >>
> >>
> >> Source File:
> >> Y:\inetpub\wwwroot\apex\webapps\dashboard\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" <dba123@.discussions.microsoft.com> wrote in message
> >> > news:0FCAE9F2-E68A-4794-9A68-BAF5877BA533@.microsoft.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
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("CurrentMonthCollections").DefaultValue =
> intCurrentMonthCollections
> and why is that var prefixed with "int" if it's a bool? Prefixing isn't
> really used much anymore anyways..
> Karl
> --
> http://www.openmymind.net/
> http://www.fuelindustries.com/
>
> "dba123" <dba123@.discussions.microsoft.com> wrote in message
> news:460D12E2-2F3F-446F-BBA3-CA80CDAE09F1@.microsoft.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("CurrentMonthCollections").DefaultValue = 1
> > Else
> > ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 0
> > End If
> > to
> > If intCurrentMonthCollections = True Then
> > ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue =
> > "true"
> > Else
> > ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue =
> > "false"
> > End If
> > The error goes away but it's still not updating those bit fields in my
> > table
> > --
> > dba123
> > "dba123" 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_DashboardGraphs"
> >> UpdateCommandType="StoredProcedure"
> >> >
> >> <UpdateParameters>
> >> <asp:Parameter Name="CustomerID" Type="Int32" />
> >> <asp:Parameter Name="Budget" Type="Int32" />
> >> <asp:Parameter Name="CurrentMonthCollections"
> >> Type="Boolean" />
> >> <asp:Parameter Name="RevenueByMonth" Type="Boolean"
> >> />
> >> <asp:Parameter Name="PDCsCCsMonthly" Type="Boolean"
> >> />
> >> <asp:Parameter Name="RevenueByClient" Type="Boolean"
> >> />
> >>
> >> </UpdateParameters>
> >>
> >> </asp:SqlDataSource>
> >>
> >>
> >> My GridView:
> >> -------
> >>
> >> <asp:GridView
> >> ID="gv_dashboard"
> >> runat="server"
> >> AutoGenerateColumns="False"
> >> DataSourceID="ds_dashboard"
> >> CellPadding="4"
> >> ForeColor="#333333"
> >> ShowFooter="True"
> >> GridLines="None"
> >> CssClass="FormatFont">
> >>
> >> <Columns>
> >> <asp:TemplateField HeaderText="Cust #"
> >> SortExpression="CustomerID">
> >> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
> >> <ItemTemplate>
> >> <asp:Label runat="server" id="lblCustomerID"
> >> Text='<%# Bind("Customer") %>' />
> >> </ItemTemplate>
> >> </asp:TemplateField>
> >> <asp:TemplateField HeaderText="Budget"
> >> SortExpression="Name"
> >> ItemStyle-HorizontalAlign="Center">
> >> <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
> >> <ItemTemplate>
> >> <asp:TextBox width="55px" MaxLength="10"
> >> ID="txtBudget" Text='<%# Bind("Budget") %>' runat="server" />
> >> </ItemTemplate>
> >> </asp:TemplateField>
> >> <asp:TemplateField HeaderText="Current Month Collections"
> >> SortExpression="Name" ItemStyle-HorizontalAlign="Center">
> >> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
> >> <ItemTemplate>
> >> <asp:checkbox runat="server"
> >> Id="chbx_CurrentMonthCollections" />
> >> </ItemTemplate>
> >> </asp:TemplateField>
> >> <asp:TemplateField HeaderText="Revenue By Month"
> >> SortExpression="Name" ItemStyle-HorizontalAlign="Center">
> >> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
> >> <ItemTemplate>
> >> <asp:checkbox runat="server"
> >> Id="chbx_RevenueByMonth" />
> >> </ItemTemplate>
> >> </asp:TemplateField>
> >> <asp:TemplateField HeaderText="PDCs & CCS Monthly"
> >> SortExpression="Name" ItemStyle-HorizontalAlign="Center">
> >> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
> >> <ItemTemplate>
> >> <asp:checkbox runat="server"
> >> Id="chbx_PDCsCCsMonthly" />
> >> </ItemTemplate>
> >> </asp:TemplateField>
> >> <asp:TemplateField HeaderText="Revenue By Client"
> >> SortExpression="Name" ItemStyle-HorizontalAlign="Center">
> >> <HeaderStyle HorizontalAlign="center"></HeaderStyle>
> >> <ItemTemplate>
> >> <asp:checkbox runat="server"
> >> Id="chbx_RevenueByClient" />
> >> </ItemTemplate>
> >> </asp:TemplateField>
> >> </Columns>
> >>
> >> <FooterStyle BackColor="#5D7B9D" Font-Bold="True"
> >> ForeColor="White" />
> >> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
> >> <EditRowStyle BackColor="#DDDDDD" />
> >> <SelectedRowStyle BackColor="#DDDDDD" Font-Bold="True"
> >> ForeColor="#333333" />
> >> <PagerStyle BackColor="#284775" ForeColor="White"
> >> HorizontalAlign="Center" />
> >> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
> >> ForeColor="White" />
> >> <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
> >> </asp:GridView>
> >>
> >>
> >> My Update Command (Stored Procedure):
> >> ----------------
> >>
> >> ALTER PROCEDURE [dbo].[aspx_Update_Customer_DashboardGraphs]
> >>
> >> @.CustomerID bigint,
> >> @.Budget int,
> >> @.CurrentMonthCollections bit,
> >> @.RevenueByMonth bit,
> >> @.PDCsCCsMonthly bit,
> >> @.RevenueByClient bit
> >>
> >> AS
> >> BEGIN
> >>
> >> UPDATE dbo.Customer_DashboardGraphs
> >> SET Budget = @.Budget,
> >> CurrentMonthCollections = @.CurrentMonthCollections,
> >> RevenueByMonth = @.RevenueByMonth,
> >> PDCsCCsMonthly = @.PDCsCCsMonthly,
> >> RevenueByClient = @.RevenueByClient
> >> WHERE Customer_DashboardGraphs.Customer = @.CustomerID
> >> END
> >>
> >>
> >> My Table Schema:
> >> --------
> >>
> >> CREATE TABLE [dbo].[Customer_DashboardGraphs](
> >> [Customer] [nchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
> >> [DashboardGraphID] [bit] NULL,
> >> [CurrentMonthCollections] [bit] NULL,
> >> [RevenueByMonth] [bit] NULL,
> >> [PDCsCCsMonthly] [bit] NULL,
> >> [RevenueByClient] [bit] NULL,
> >> [Budget] [int] NULL
> >> ) ON [PRIMARY]
> >> Stack Trace:
> >>
> >> String was not recognized as a valid Boolean.
> >> Description: An unhandled exception occurred during the execution of the
> >> current web request. Please review the stack trace for more information
> >> about
> >> the error and where it originated in the code.
> >>
> >> Exception Details: System.FormatException: String was not recognized as a
> >> valid Boolean.
> >>
> >> Source Error:
> >>
> >>
> >> Line 53:
> >> ds_dashboard.UpdateParameters("Budget").DefaultValue = intBudget
> >> Line 54:
> >> Line 55: ds_dashboard.Update()
> >> Line 56: End If
> >> Line 57: Next
> >>
> >>
> >> Source File:
> >> Y:\inetpub\wwwroot\apex\webapps\dashboard\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" <dba123@.discussions.microsoft.com> wrote in message
> >> > news:0FCAE9F2-E68A-4794-9A68-BAF5877BA533@.microsoft.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
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" <dba123@.discussions.microsoft.com> wrote in message
news:575A281C-2B41-41BD-AC49-3F5A8F0A207B@.microsoft.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_CurrentMonthCollections"), CheckBox).Checked
>> Dim intRevenueByMonth As Boolean =
>> CType(gvr.FindControl("chbx_RevenueByMonth"), CheckBox).Checked
>> Dim intPDCsCCsMonthly As Boolean =
>> CType(gvr.FindControl("chbx_PDCsCCsMonthly"), CheckBox).Checked
>> Dim intRevenueByClient As Boolean =
>> CType(gvr.FindControl("chbx_RevenueByClient"), CheckBox).Checked
>>
>> '//--Assign UpdateParameters
>> If intCurrentMonthCollections = True Then
>>
>> ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 1
>> Else
>>
>> ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 0
>> End If
>> ...
>>
>> ds_dashboard.UpdateParameters("Budget").DefaultValue =
>> intBudget
>>
>> ds_dashboard.Update()
>> End If
>> Next
>> End Sub
>> --
>> dba123
Thanks you are correct. What I did was changed my SelectCommand stored proc
to replace the nulls with 0 instead.

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

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

<asp:SqlDataSource
ID="ds_dashboard"
runat="server"
ConnectionString="<%$ ConnectionStrings:DashboardConn %>"
SelectCommand="aspx_Get_Customer_DashboardGraphs"
SelectCommandType="StoredProcedure"
UpdateCommand="aspx_Update_Customer_DashboardGraphs"
UpdateCommandType="StoredProcedure"
<UpdateParameters>
<asp:Parameter Name="CustomerID" Type="Int32" />
<asp:Parameter Name="Budget" Type="Int32" />
<asp:Parameter Name="CurrentMonthCollections"
Type="Boolean" />
<asp:Parameter Name="RevenueByMonth" Type="Boolean" />
<asp:Parameter Name="PDCsCCsMonthly" Type="Boolean" />
<asp:Parameter Name="RevenueByClient" Type="Boolean" /
</UpdateParameters
</asp:SqlDataSource
<asp:GridView
ID="gv_dashboard"
runat="server"
AutoGenerateColumns="False"
DataSourceID="ds_dashboard"
CellPadding="4"
ForeColor="#333333"
ShowFooter="True"
GridLines="None"
CssClass="FormatFont"
<Columns>
<asp:TemplateField HeaderText="Cust #"
SortExpression="CustomerID">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:Label runat="server" id="lblCustomerID"
Text='<%# Bind("Customer") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Budget" SortExpression="Name"
ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
<ItemTemplate>
<asp:TextBox width="55px" MaxLength="10"
ID="txtBudget" Text='<%# Bind("Budget") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Current Month Collections"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_CurrentMonthCollections" Checked='<%#
Bind("CurrentMonthCollections") %>'/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Revenue By Month"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_RevenueByMonth" Checked='<%# Bind("RevenueByMonth") %>'/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="PDCs & CCS Monthly"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_PDCsCCsMonthly" Checked='<%# Bind("PDCsCCsMonthly") %>'/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Revenue By Client"
SortExpression="Name" ItemStyle-HorizontalAlign="Center">
<HeaderStyle HorizontalAlign="center"></HeaderStyle>
<ItemTemplate>
<asp:checkbox runat="server"
Id="chbx_RevenueByClient" Checked='<%# Bind("RevenueByClient") %>'/>
</ItemTemplate>
</asp:TemplateField>
</Columns
<FooterStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#DDDDDD" />
<SelectedRowStyle BackColor="#DDDDDD" Font-Bold="True"
ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White"
HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True"
ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" /
</asp:GridView
Stored proc behind the Select Command

ALTER PROCEDURE [dbo].[aspx_Get_Customer_DashboardGraphs]

AS
BEGIN

SELECTCustomer,
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]

@.CustomerIDbigint,
@.Budgetbigint,
@.CurrentMonthCollectionsbit,
@.RevenueByMonthbit,
@.PDCsCCsMonthlybit,
@.RevenueByClientbit

AS
BEGIN

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

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

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

'//--IDs

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

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

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

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

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

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

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

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

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

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

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

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

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

ds_dashboard.Update()
End If
Next
End Sub

--
dba123

"Karl Seguin [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" <dba123@.discussions.microsoft.com> wrote in message
> news:575A281C-2B41-41BD-AC49-3F5A8F0A207B@.microsoft.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_CurrentMonthCollections"), CheckBox).Checked
> >> Dim intRevenueByMonth As Boolean =
> >> CType(gvr.FindControl("chbx_RevenueByMonth"), CheckBox).Checked
> >> Dim intPDCsCCsMonthly As Boolean =
> >> CType(gvr.FindControl("chbx_PDCsCCsMonthly"), CheckBox).Checked
> >> Dim intRevenueByClient As Boolean =
> >> CType(gvr.FindControl("chbx_RevenueByClient"), CheckBox).Checked
> >>
> >> '//--Assign UpdateParameters
> >> If intCurrentMonthCollections = True Then
> >>
> >> ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 1
> >> Else
> >>
> >> ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 0
> >> End If
> >> ...
> >>
> >> ds_dashboard.UpdateParameters("Budget").DefaultValue =
> >> intBudget
> >>
> >> ds_dashboard.Update()
> >> End If
> >> Next
> >> End Sub
> >> --
> >> dba123
>
'<%# ( 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" <dba123@.discussions.microsoft.com> wrote in message
> news:575A281C-2B41-41BD-AC49-3F5A8F0A207B@.microsoft.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_CurrentMonthCollections"), CheckBox).Checked
> >> Dim intRevenueByMonth As Boolean =
> >> CType(gvr.FindControl("chbx_RevenueByMonth"), CheckBox).Checked
> >> Dim intPDCsCCsMonthly As Boolean =
> >> CType(gvr.FindControl("chbx_PDCsCCsMonthly"), CheckBox).Checked
> >> Dim intRevenueByClient As Boolean =
> >> CType(gvr.FindControl("chbx_RevenueByClient"), CheckBox).Checked
> >>
> >> '//--Assign UpdateParameters
> >> If intCurrentMonthCollections = True Then
> >>
> >> ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 1
> >> Else
> >>
> >> ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = 0
> >> End If
> >> ...
> >>
> >> ds_dashboard.UpdateParameters("Budget").DefaultValue =
> >> intBudget
> >>
> >> ds_dashboard.Update()
> >> End If
> >> Next
> >> End Sub
> >> --
> >> dba123
>

Saturday, March 24, 2012

Strip characters from string

Hi, I want the user to be able to enter any form of number in my price textbox and I will automatically strip anything that is not an integer.

I obviously can't mand a string.replace for every character, so is there a way to use a regexp to say anything that isnt 0-9?

Thanks, Davehello, u can add a validation control to the textbox with the following:

[0-9]+

this way, they can enter any number they want.
But I don't want to have to restrict it like that. Many people will enter different formats for a price. I want them to be able to use '$' or ',' or whatever and have it stripped on the backend.

I am looking at regex.replace, but I can't get it to work yet.
well,
maybe u can allow them to enter any number or character and the loop through an array of all alphabets and eleminate all not needed characters !!!
I can offer you a commercial solution. My productProfessional Validation And More includes IntegerTextBox, CurrencyTextBox, and DecimalTextBox fields. They handle the filtering of illegal keystrokes, reformatting as the user exits the field, and supply you with the actual numeric value (an integer or Double property) on the server side.

strip out any html code from textbox

Hi! I am looking for a way to stip out any html code if the user type in some html in the textbox. Thanks!!

If the ValidateRequest is turned on for a page then ASP.Net will automatically detect the HTML in the text box and throw an error.

ValidateRequest can be turned on in the Page directive.


use

yourString= Server.HtmlEncode(Trim(TxtBxManufactureProductID.Text))

or
yourString=HttpUtility.HtmlEncode(TxtBxManufactureProductID.Text)

yourString is a string variable


Use can use HTMLEncode as told previously, else if you want to completely remove HTML then you may user RegEx. <(?<tag>\w*)>(?<text>.*)</\k<tag>> , and replace them with some empty string.

I am not sure of the exact code, but you can replace HTML for sure.

Ankit


Hi! Thank you for the reply, I tried yourString=HttpUtility.HtmlEncode(TxtProfile.Text) and got an error ( a potentially dangerous request...)

And I also tried the one that has Trim,but it says that Trim doesn't exist in the current contest. Do I have to import a namespace for that? Thanks.


Thanks! I get a syntax error on the reguloar expression:

<asp:RegularExpressionValidatorID="RegularExpressionValidator1"runat="server"ControlToValidate="txtBusinessprofile"ValidationExpression="<(?<tag>\w*)>(?<text>.*)</\k<tag>>">Please do not incluse html code!</asp:RegularExpressionValidator>


<%@. Page Language="VB" MasterPageFile="AdminMasterPage.master" AutoEventWireup="false" Inherits="YYY" title="xxxx"ValidateRequest="false" Codebehind="YYY.aspx.vb" %>

you will have a line like above in your axpx file(the fist line)

write the ValidateRequest="false" there

Then also use codes in my previous replay


Do you know how to catch the exception that is thrown when ValidationRequest="true" and user inputs an html? I can see that this exception is fired much before the execution point ever comes the actual page's codebehind. I guess i could not even catch it in Application_Error.....

It will be actually nice to have something like this:

1. keep ValidationRequest="true"

2. Exception is thrown if user enters html or anything inside angular brackets

3. Error is caught at Page error handler and action is taken (display msg etc)

This will save remembering to validate for malicious input (or at least a scripting type of malicious input) in all the forms in all the pages...


Thanks for the tip! I have also read that it's not a good habit to set validaterequest to false cos of the script injection attacks that might arise...I had mine set to false for the page only and I need to make sure that all html code is stripped out of the textbox.

Strong Naming an ASP.Net Project

Hello,

I have a Web Project (UserControls.dll) with some user controls that
is shared by many asp.net web applicattions.

What we do is copy UserControls.dll to all the applications bin
folders an this works correctly.

We want to have this shared code in the GAC.

Wit other non-web projects we create a snk file, add it to the project
and compile. Later we register this dll manually in the GAC.

I have been trying to do this with a web project , and all the time I
get an error saying that it cannot read the snk file.

Is it possible to strong name the generated dll of a web project?

Thanks in Advance.

ManuelYes it is, but with ASP.NET there are two places where a binary is built.
You may have to put the strong name in the temporary directory where things
are built:

c:\documents and
settings\<userName>\VSWebCache\<machineName>\<applicationName
--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"Manuel Lopez" <mcpollo@.terra.es> wrote in message
news:cd080612.0312010830.45b95557@.posting.google.c om...
> Hello,
> I have a Web Project (UserControls.dll) with some user controls that
> is shared by many asp.net web applicattions.
> What we do is copy UserControls.dll to all the applications bin
> folders an this works correctly.
> We want to have this shared code in the GAC.
> Wit other non-web projects we create a snk file, add it to the project
> and compile. Later we register this dll manually in the GAC.
> I have been trying to do this with a web project , and all the time I
> get an error saying that it cannot read the snk file.
> Is it possible to strong name the generated dll of a web project?
> Thanks in Advance.
> Manuel
Hello Chris,

Thanks for the reply.

Our problem is that we cannot compile our web project with
the user controls when we add a snk file and reference it
from Assembly file.

It seems as if you cannot use then with web projects.

>--Original Message--
>Yes it is, but with ASP.NET there are two places where a
binary is built.
>You may have to put the strong name in the temporary
directory where things
>are built:
>c:\documents and
>settings\<userName>\VSWebCache\<machineName>\<applicationN
ame>
>
>--
>Chris Jackson
>Software Engineer
>Microsoft MVP - Windows Client
>Windows XP Associate Expert
>--
>More people read the newsgroups than read my email.
>Reply to the newsgroup for a faster response.
>(Control-G using Outlook Express)
>--
>"Manuel Lopez" <mcpollo@.terra.es> wrote in message
>news:cd080612.0312010830.45b95557@.posting.google.c om...
>> Hello,
>>
>> I have a Web Project (UserControls.dll) with some user
controls that
>> is shared by many asp.net web applicattions.
>>
>> What we do is copy UserControls.dll to all the
applications bin
>> folders an this works correctly.
>>
>> We want to have this shared code in the GAC.
>>
>> Wit other non-web projects we create a snk file, add it
to the project
>> and compile. Later we register this dll manually in the
GAC.
>>
>> I have been trying to do this with a web project , and
all the time I
>> get an error saying that it cannot read the snk file.
>>
>> Is it possible to strong name the generated dll of a
web project?
>>
>> Thanks in Advance.
>>
>> Manuel
>
>.
I may be missing what you are asking here. Are you trying to compile the
project you are strong naming and failing? If that is the case, then you
need to move the SNK file. The error that is generated should tell you the
directory it is searching in and failing to find it. Have you compiled and
strong named an assembly, and having trouble referencing it? You should
definitely be able to reference a strong named file - that also works. You
just need to make sure it is in the search path. What is the error that you
are seeing?

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"Manuel Lopez" <anonymous@.discussions.microsoft.com> wrote in message
news:0ae201c3b833$8a338160$a501280a@.phx.gbl...
> Hello Chris,
> Thanks for the reply.
> Our problem is that we cannot compile our web project with
> the user controls when we add a snk file and reference it
> from Assembly file.
> It seems as if you cannot use then with web projects.
>
> >--Original Message--
> >Yes it is, but with ASP.NET there are two places where a
> binary is built.
> >You may have to put the strong name in the temporary
> directory where things
> >are built:
> >c:\documents and
> >settings\<userName>\VSWebCache\<machineName>\<applicationN
> ame>
> >--
> >Chris Jackson
> >Software Engineer
> >Microsoft MVP - Windows Client
> >Windows XP Associate Expert
> >--
> >More people read the newsgroups than read my email.
> >Reply to the newsgroup for a faster response.
> >(Control-G using Outlook Express)
> >--
> >"Manuel Lopez" <mcpollo@.terra.es> wrote in message
> >news:cd080612.0312010830.45b95557@.posting.google.c om...
> >> Hello,
> >>
> >> I have a Web Project (UserControls.dll) with some user
> controls that
> >> is shared by many asp.net web applicattions.
> >>
> >> What we do is copy UserControls.dll to all the
> applications bin
> >> folders an this works correctly.
> >>
> >> We want to have this shared code in the GAC.
> >>
> >> Wit other non-web projects we create a snk file, add it
> to the project
> >> and compile. Later we register this dll manually in the
> GAC.
> >>
> >> I have been trying to do this with a web project , and
> all the time I
> >> get an error saying that it cannot read the snk file.
> >>
> >> Is it possible to strong name the generated dll of a
> web project?
> >>
> >> Thanks in Advance.
> >>
> >> Manuel
> >.
Hello Again Chris,

My problem is that i cant generate the strong name "web"
project.

The snk file is the at the same level of of vbproj file,
and in assembly i have :

<Assembly: AssemblyKeyFile("..\..\Keys.snk")>

I have tried copying the snk file to the bin directory,
changing the path and it just doesnt work for a "Web"
project.

Maybe you just cant strong name a "Web" through Visual
Studio.

Thanks

>--Original Message--
>I may be missing what you are asking here. Are you trying
to compile the
>project you are strong naming and failing? If that is the
case, then you
>need to move the SNK file. The error that is generated
should tell you the
>directory it is searching in and failing to find it. Have
you compiled and
>strong named an assembly, and having trouble referencing
it? You should
>definitely be able to reference a strong named file -
that also works. You
>just need to make sure it is in the search path. What is
the error that you
>are seeing?
>--
>Chris Jackson
>Software Engineer
>Microsoft MVP - Windows Client
>Windows XP Associate Expert
>--
>More people read the newsgroups than read my email.
>Reply to the newsgroup for a faster response.
>(Control-G using Outlook Express)
>--
>"Manuel Lopez" <anonymous@.discussions.microsoft.com>
wrote in message
>news:0ae201c3b833$8a338160$a501280a@.phx.gbl...
>> Hello Chris,
>>
>> Thanks for the reply.
>>
>> Our problem is that we cannot compile our web project
with
>> the user controls when we add a snk file and reference
it
>> from Assembly file.
>>
>> It seems as if you cannot use then with web projects.
>>
>>
>> >--Original Message--
>> >Yes it is, but with ASP.NET there are two places where
a
>> binary is built.
>> >You may have to put the strong name in the temporary
>> directory where things
>> >are built:
>>> >c:\documents and
>>
>settings\<userName>\VSWebCache\<machineName>\<applicationN
>> ame>
>>>> >--
>> >Chris Jackson
>> >Software Engineer
>> >Microsoft MVP - Windows Client
>> >Windows XP Associate Expert
>> >--
>> >More people read the newsgroups than read my email.
>> >Reply to the newsgroup for a faster response.
>> >(Control-G using Outlook Express)
>> >--
>>> >"Manuel Lopez" <mcpollo@.terra.es> wrote in message
>> >news:cd080612.0312010830.45b95557@.posting.google.c om...
>> >> Hello,
>> >>
>> >> I have a Web Project (UserControls.dll) with some
user
>> controls that
>> >> is shared by many asp.net web applicattions.
>> >>
>> >> What we do is copy UserControls.dll to all the
>> applications bin
>> >> folders an this works correctly.
>> >>
>> >> We want to have this shared code in the GAC.
>> >>
>> >> Wit other non-web projects we create a snk file, add
it
>> to the project
>> >> and compile. Later we register this dll manually in
the
>> GAC.
>> >>
>> >> I have been trying to do this with a web project ,
and
>> all the time I
>> >> get an error saying that it cannot read the snk file.
>> >>
>> >> Is it possible to strong name the generated dll of a
>> web project?
>> >>
>> >> Thanks in Advance.
>> >>
>> >> Manuel
>>>> >.
>>
>.
You can strong name it, you just have to manually drag the SNK file to the
VSWebCache folder (as indicated in my first post). VS.NET does not provide
the mechanisms, though the error message should help you locate the proper
directory. The folder in inetpub is NOT where it goes. I have done it
before, I just don't have any on this machine to give you the exact
location, but I promise you that it works.

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"Manuel Lopez" <anonymous@.discussions.microsoft.com> wrote in message
news:afa901c3b8b6$b56a0a10$a601280a@.phx.gbl...
Hello Again Chris,

My problem is that i cant generate the strong name "web"
project.

The snk file is the at the same level of of vbproj file,
and in assembly i have :

<Assembly: AssemblyKeyFile("..\..\Keys.snk")
I have tried copying the snk file to the bin directory,
changing the path and it just doesnt work for a "Web"
project.

Maybe you just cant strong name a "Web" through Visual
Studio.

Thanks

>--Original Message--
>I may be missing what you are asking here. Are you trying
to compile the
>project you are strong naming and failing? If that is the
case, then you
>need to move the SNK file. The error that is generated
should tell you the
>directory it is searching in and failing to find it. Have
you compiled and
>strong named an assembly, and having trouble referencing
it? You should
>definitely be able to reference a strong named file -
that also works. You
>just need to make sure it is in the search path. What is
the error that you
>are seeing?
>--
>Chris Jackson
>Software Engineer
>Microsoft MVP - Windows Client
>Windows XP Associate Expert
>--
>More people read the newsgroups than read my email.
>Reply to the newsgroup for a faster response.
>(Control-G using Outlook Express)
>--
>"Manuel Lopez" <anonymous@.discussions.microsoft.com>
wrote in message
>news:0ae201c3b833$8a338160$a501280a@.phx.gbl...
>> Hello Chris,
>>
>> Thanks for the reply.
>>
>> Our problem is that we cannot compile our web project
with
>> the user controls when we add a snk file and reference
it
>> from Assembly file.
>>
>> It seems as if you cannot use then with web projects.
>>
>>
>> >--Original Message--
>> >Yes it is, but with ASP.NET there are two places where
a
>> binary is built.
>> >You may have to put the strong name in the temporary
>> directory where things
>> >are built:
>>> >c:\documents and
>>
>settings\<userName>\VSWebCache\<machineName>\<applicationN
>> ame>
>>>> >--
>> >Chris Jackson
>> >Software Engineer
>> >Microsoft MVP - Windows Client
>> >Windows XP Associate Expert
>> >--
>> >More people read the newsgroups than read my email.
>> >Reply to the newsgroup for a faster response.
>> >(Control-G using Outlook Express)
>> >--
>>> >"Manuel Lopez" <mcpollo@.terra.es> wrote in message
>> >news:cd080612.0312010830.45b95557@.posting.google.c om...
>> >> Hello,
>> >>
>> >> I have a Web Project (UserControls.dll) with some
user
>> controls that
>> >> is shared by many asp.net web applicattions.
>> >>
>> >> What we do is copy UserControls.dll to all the
>> applications bin
>> >> folders an this works correctly.
>> >>
>> >> We want to have this shared code in the GAC.
>> >>
>> >> Wit other non-web projects we create a snk file, add
it
>> to the project
>> >> and compile. Later we register this dll manually in
the
>> GAC.
>> >>
>> >> I have been trying to do this with a web project ,
and
>> all the time I
>> >> get an error saying that it cannot read the snk file.
>> >>
>> >> Is it possible to strong name the generated dll of a
>> web project?
>> >>
>> >> Thanks in Advance.
>> >>
>> >> Manuel
>>>> >.
>>
>.
I guess I should point out, for the sake of completeness, that this may not
be the best idea. The reason I have strong named ASP.NET assemblies is
basically just to see if it can be done. (Well, FXCop was barking...)
However, note that the model for ASP.NET is not *complete* compilation, but
rather compilation of the code behind, followed by JIT compilation of the
declarative ASPX page. So, your derived forms won't actually exist in the
strong named assembly. What you should consider is developing a class
library of classes that derive from the UserControl class to provide the
basic functionality that you need, and then provide declarative pages whose
code behind inherits from this. This just occurred to me, so I figured I
would add this appendix...

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message
news:%23RN%23aIPuDHA.3256@.TK2MSFTNGP11.phx.gbl...
> You can strong name it, you just have to manually drag the SNK file to the
> VSWebCache folder (as indicated in my first post). VS.NET does not provide
> the mechanisms, though the error message should help you locate the proper
> directory. The folder in inetpub is NOT where it goes. I have done it
> before, I just don't have any on this machine to give you the exact
> location, but I promise you that it works.
> --
> Chris Jackson
> Software Engineer
> Microsoft MVP - Windows Client
> Windows XP Associate Expert
> --
> More people read the newsgroups than read my email.
> Reply to the newsgroup for a faster response.
> (Control-G using Outlook Express)
> --
> "Manuel Lopez" <anonymous@.discussions.microsoft.com> wrote in message
> news:afa901c3b8b6$b56a0a10$a601280a@.phx.gbl...
> Hello Again Chris,
> My problem is that i cant generate the strong name "web"
> project.
> The snk file is the at the same level of of vbproj file,
> and in assembly i have :
> <Assembly: AssemblyKeyFile("..\..\Keys.snk")>
> I have tried copying the snk file to the bin directory,
> changing the path and it just doesnt work for a "Web"
> project.
> Maybe you just cant strong name a "Web" through Visual
> Studio.
> Thanks
> >--Original Message--
> >I may be missing what you are asking here. Are you trying
> to compile the
> >project you are strong naming and failing? If that is the
> case, then you
> >need to move the SNK file. The error that is generated
> should tell you the
> >directory it is searching in and failing to find it. Have
> you compiled and
> >strong named an assembly, and having trouble referencing
> it? You should
> >definitely be able to reference a strong named file -
> that also works. You
> >just need to make sure it is in the search path. What is
> the error that you
> >are seeing?
> >--
> >Chris Jackson
> >Software Engineer
> >Microsoft MVP - Windows Client
> >Windows XP Associate Expert
> >--
> >More people read the newsgroups than read my email.
> >Reply to the newsgroup for a faster response.
> >(Control-G using Outlook Express)
> >--
> >"Manuel Lopez" <anonymous@.discussions.microsoft.com>
> wrote in message
> >news:0ae201c3b833$8a338160$a501280a@.phx.gbl...
> >> Hello Chris,
> >>
> >> Thanks for the reply.
> >>
> >> Our problem is that we cannot compile our web project
> with
> >> the user controls when we add a snk file and reference
> it
> >> from Assembly file.
> >>
> >> It seems as if you cannot use then with web projects.
> >>
> >>
> >> >--Original Message--
> >> >Yes it is, but with ASP.NET there are two places where
> a
> >> binary is built.
> >> >You may have to put the strong name in the temporary
> >> directory where things
> >> >are built:
> >> >> >c:\documents and
> >>
> >settings\<userName>\VSWebCache\<machineName>\<applicationN
> >> ame>
> >> >> >> >--
> >> >Chris Jackson
> >> >Software Engineer
> >> >Microsoft MVP - Windows Client
> >> >Windows XP Associate Expert
> >> >--
> >> >More people read the newsgroups than read my email.
> >> >Reply to the newsgroup for a faster response.
> >> >(Control-G using Outlook Express)
> >> >--
> >> >> >"Manuel Lopez" <mcpollo@.terra.es> wrote in message
> >> >news:cd080612.0312010830.45b95557@.posting.google.c om...
> >> >> Hello,
> >> >>
> >> >> I have a Web Project (UserControls.dll) with some
> user
> >> controls that
> >> >> is shared by many asp.net web applicattions.
> >> >>
> >> >> What we do is copy UserControls.dll to all the
> >> applications bin
> >> >> folders an this works correctly.
> >> >>
> >> >> We want to have this shared code in the GAC.
> >> >>
> >> >> Wit other non-web projects we create a snk file, add
> it
> >> to the project
> >> >> and compile. Later we register this dll manually in
> the
> >> GAC.
> >> >>
> >> >> I have been trying to do this with a web project ,
> and
> >> all the time I
> >> >> get an error saying that it cannot read the snk file.
> >> >>
> >> >> Is it possible to strong name the generated dll of a
> >> web project?
> >> >>
> >> >> Thanks in Advance.
> >> >>
> >> >> Manuel
> >> >> >> >.
> >> >.