troubleshooting Question

VB.Net Build string based on DataGridView values from a single column

Avatar of Wilder1626
Wilder1626Flag for Canada asked on
Visual Basic.NET
4 Comments1 Solution8 ViewsLast Modified:

Hi

I have this problem generating a string based on all the values from a DataGridView column.


Ex. If in my grid, i have:


I would like to generate a string that will be puted into my txEquipmentCompatibilityString.Text as below:

('010','050','063','069')

The problem i have is that i only get ('010') with the below code:

'Build String
        Dim s As String

        For n = 0 To dgvLoadCommodities.RowCount - 1

            If String.IsNullOrEmpty(dgvLoadCommodities.Rows(n).Cells(0).Value) Then
            Else
                s = "'" + dgvLoadCommodities.Rows(n).Cells(0).Value.ToString.Replace("'", "''") + "'"
            End If
        Next

        txEquipmentCompatibilityString.Text = "" & "(" + " '" + dgvLoadCommodities.Rows(0).Cells(0).Value.ToString.Replace("'", "''") + "')"


How can i fix that.


Thanks again for your help.

ASKER CERTIFIED SOLUTION
Éric Moreau
Senior .Net Consultant
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros