Advertisement

07.05.2007 at 08:44AM PDT, ID: 22677073
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.8

Filtered Data View Update

Asked by Millkind in Microsoft Visual Basic.Net

Tags: ,

The problem I am having is that I am using a filtered dataview in a datagrid.  It is filtered on a yes/no column called printed.  Eventually the user highlights the rows they want to print and clicks the print button.   First this clears the print dataset then causes the highlighted rows to be written to the print dataset, that part works fine.  After that is done I want to mark the printed as yes in all the rows that have been printed.  Unfortunately as soon as you mark the yes/no printed it filters it out causing the for loop to lose it place which means it either starts marking the wrong row or go outside the bounds of the dataview causing an error.  I have tried unfiltering the dataview before I start the print process but that causes the rows highlighted by the user to become unhighlighted. The reason I'm putting the choices into an arraylist and doing the later is for the same reason.

Here is how the datagrid is setup with the dataview and filter.
            forwardinglisttempset = New DataSet
            flda.Fill(forwardinglisttempset)
            forwardinglistgrid.DataSource = forwardinglisttempset.Tables(0)
            forwardinglistview = New DataView(forwardinglistgrid.DataSource)
            forwardinglistgrid.DataSource = forwardinglistview
            flda.TableMappings.Clear()
            flda.TableMappings.Add("forwardinglisttempset.Tables(0)", "forwardinglistview")
            Dim command_builder = New Odbc.OdbcCommandBuilder(flda)
            forwardinglistview.RowFilter = "printed = " & False

Here is the code that is activated when the print button is clicked:
Try
                'setup
                Dim marked As New ArrayList
                Flprintds1.Clear()
                flprintda.Fill(Flprintds1)
                Dim command_builder = New Odbc.OdbcCommandBuilder(flprintda)
                'delete current print record
                For Each tr As DataRow In Flprintds1.Tables(0).Rows
                    tr.Delete()
                Next
                'add highlighted rows for printing
                For i As Integer = 0 To forwardinglistview.Count - 1
                    If forwardinglistgrid.IsSelected(i) Then
                        rowTemp = Flprintds1.Tables(0).NewRow()
                        rowTemp.Item("trackingnumber") = fis(forwardinglistgrid.Item(i, 1).ToString)
                        rowTemp.Item("lastname") = fis(forwardinglistgrid.Item(i, 2).ToString)
                        rowTemp.Item("firstname") = fis(forwardinglistgrid.Item(i, 3).ToString)
                        rowTemp.Item("middlename") = fis(forwardinglistgrid.Item(i, 4).ToString)
                        rowTemp.Item("address1") = fis(forwardinglistgrid.Item(i, 9).ToString)
                        rowTemp.Item("address2") = fis(forwardinglistgrid.Item(i, 10).ToString)
                        rowTemp.Item("city") = fis(forwardinglistgrid.Item(i, 11).ToString)
                        rowTemp.Item("state") = fis(forwardinglistgrid.Item(i, 12).ToString)
                        rowTemp.Item("zip") = fis(forwardinglistgrid.Item(i, 13).ToString)
                        rowTemp.Item("country") = fis(forwardinglistgrid.Item(i, 14).ToString)
                       'add printed rows to be marked later
                        marked.Add(forwardinglistgrid.Item(i, 1))
                        Flprintds1.Tables(0).Rows.Add(rowTemp)
                    End If
                Next

                'mark highlighted rows as printed
                For i As Integer = 0 To marked.Count - 1
                    forwardinglistgrid.Item(marked(i), 15) = True
                Next

                'instert empties for blanks on label sheet
                For j As Integer = 1 To empties.Text
                    rowTemp = Flprintds1.Tables(0).NewRow()
                    rowTemp.Item("trackingnumber") = Format(Date.Now, "yyyyMMddHHmmssfffffff") & j
                    Flprintds1.Tables(0).Rows.Add(rowTemp)
                Next

                'update the print table in the database
                flprintda.Update(Flprintds1)
                'activate the print macro in the database DEACTIVATED FOR TESTING
                'RunMacro("printforwrdinglistreport")
                showforwardgrid()
            Catch ex As Exception
                errorwrite(ex.ToString)
            End TryStart Free Trial
[+][-]07.05.2007 at 09:19AM PDT, ID: 19425235

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.05.2007 at 12:03PM PDT, ID: 19426392

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual Basic.Net
Tags: dataview, update
Sign Up Now!
Solution Provided By: Sancler
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.05.2007 at 12:16PM PDT, ID: 19426478

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32