Help with checkbox update function in GridView for GridView.Rows

I need help with the syntax below to finish my function which will be the update function for the onclick event for the submit button that will update all checkboxes in my GridView.  So far, I'm close but not getting quite the right syntax:

    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
                Dim intCustomerID As Integer = CType(gvr.FindControl("lblCustomerID"), Label).Text.Trim()
                Dim intCurrentMonthCollections As CheckBox = gvr.FindControl("chbx_CurrentMonthCollections")
                Dim intRevenueByMonth As CheckBox = gvr.FindControl("chbx_RevenueByMonth")
                Dim intPDCsCCsMonthly As CheckBox = gvr.FindControl("chbx_PDCsCCsMonthly")
                Dim intRevenueByClient As CheckBox = gvr.FindControl("chbx_RevenueByClient")

                ds_dashboard.UpdateParameters("CustomerID").DefaultValue = intCustomerID
                ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = intCurrentMonthCollections
                ds_dashboard.UpdateParameters("RevenueByMonth").DefaultValue = intRevenueByMonth
                ds_dashboard.UpdateParameters("PDCsCCsMonthly").DefaultValue = intPDCsCCsMonthly
                ds_dashboard.UpdateParameters("RevenueByClient").DefaultValue = intRevenueByClient
                ds_dashboard.Update()
            End If
        Next
    End Sub

My SQLDtaSource:

        <asp:SqlDataSource
            ID="ds_dashboard"
            runat="server"
            ConnectionString="<%$ ConnectionStrings:DashboardConn %>"
            SelectCommand="Get_Customer_DashboardGraphs"
            SelectCommandType="StoredProcedure"
            UpdateCommand="Update_Customer_DashboardGraphs"
            UpdateCommandType="StoredProcedure"
            >
            <UpdateParameters>
                    <asp:Parameter Name="CustomerID" 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>


Errors I'm getting with my function:

Value of type 'System.Web.UI.WebControls.CheckBox' cannot be converted to 'String'
...
LVL 1
dba123Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

junglerover77Commented:
The following code is wrong, how can you assign a checkbox to a value?

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = intCurrentMonthCollections
                ds_dashboard.UpdateParameters("RevenueByMonth").DefaultValue = intRevenueByMonth
                ds_dashboard.UpdateParameters("PDCsCCsMonthly").DefaultValue = intPDCsCCsMonthly
                ds_dashboard.UpdateParameters("RevenueByClient").DefaultValue = intRevenueByClient
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Just Change it to:

                ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = intCurrentMonthCollections.checked
                ds_dashboard.UpdateParameters("RevenueByMonth").DefaultValue = intRevenueByMonth.checked
                ds_dashboard.UpdateParameters("PDCsCCsMonthly").DefaultValue = intPDCsCCsMonthly.checked
                ds_dashboard.UpdateParameters("RevenueByClient").DefaultValue = intRevenueByClient.checked
dba123Author Commented:
hehehe, Jungle, I have to chuckle ast your reponse a little...Yes, I know it's wrong :)  That's why I'm posting this question, because I couldn't find the right syntax or an article explaining this anywhere so I posted this in EE>  I don't know how I can assigne a checkbox to a value, I was just experimenting since I had nothing to go by.

Thank you, I will try your suggestion.
dba123Author Commented:
what about this part though:

                Dim intCurrentMonthCollections As CheckBox = CType(gvr.FindControl("chbx_CurrentMonthCollections"), CheckBox)
                Dim intRevenueByMonth As CheckBox = gvr.FindControl("chbx_RevenueByMonth")
                Dim intPDCsCCsMonthly As CheckBox = gvr.FindControl("chbx_PDCsCCsMonthly")
                Dim intRevenueByClient As CheckBox = gvr.FindControl("chbx_RevenueByClient")
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

dba123Author Commented:
If I try this, I get an error saying it cannot convert to Boolean

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

Error: Value of type 'System.Web.UI.Control' cannot be converted to 'Boolean'.

so what is the correct syntax?  It's amazing to me that I have to search so hard to find this on the net
dba123Author Commented:
Ok, I played around with it, I may have it?

    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
                Dim intCustomerID As Integer = CType(gvr.FindControl("lblCustomerID"), Label).Text.Trim()
                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

                'ds_dashboard.UpdateParameters("CustomerID").DefaultValue = intCustomerID
                ds_dashboard.UpdateParameters("CurrentMonthCollections").DefaultValue = intCurrentMonthCollections
                ds_dashboard.UpdateParameters("RevenueByMonth").DefaultValue = intRevenueByMonth
                ds_dashboard.UpdateParameters("PDCsCCsMonthly").DefaultValue = intPDCsCCsMonthly
                ds_dashboard.UpdateParameters("RevenueByClient").DefaultValue = intRevenueByClient
                ds_dashboard.Update()
            End If
        Next
    End Sub
junglerover77Commented:
Yes, you are right. I do forgot to force the control to the right type before using its "checked" property.
dba123Author Commented:
And the answer is:

    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

....

                '//--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
                Dim bolArizona As Boolean = CType(gvr.FindControl("chbx_Arizona"), CheckBox).Checked
                Dim bolIllinois As Boolean = CType(gvr.FindControl("chbx_Illinois"), CheckBox).Checked

...

                ds_dashboard.Update()
            End If
        Next
    End Sub
GranModCommented:
Closed, 500 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.