Posted 7 September 2019, 9:14 am EST
Hello,
I using the code below to search data in C1AOP5 by entering multiple values in one more rows in the AOP6A DataGrid. How do you modify the code to achieve the same with a FlexGrid in an ASP.NET MVC application? Button click event activates AOP6VIEW method.
For example, if I enter BEL,USA in Row1 and 10411 in Row2, C1AOP5 should display all the records where both BEL and USA are included in 10411 from C1AOP5.
If possible please send me a sample project with the solution.
Private Sub AOP6A_CellValueChanged(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles AOP6A.CellValueChanged
If e.ColumnIndex = 0 Then
If AOP6A.Columns(e.ColumnIndex).Name = “CheckBoxColumn” Then
Dim checkCell As DataGridViewCheckBoxCell =
CType(AOP6A.Rows(e.RowIndex).Cells(“CheckBoxColumn”),
DataGridViewCheckBoxCell)
If CType(checkCell.Value, [Boolean]) = True Then
AOP6A.Rows(e.RowIndex).Cells(“CheckBoxColumn”).Style.BackColor = Color.Blue
AOP6A.Rows(e.RowIndex).Cells(“CheckBoxColumn”).Style.SelectionBackColor = Color.Blue
AOP6A.Rows(e.RowIndex).DefaultCellStyle.BackColor = Color.Blue
AOP6A.Rows(e.RowIndex).DefaultCellStyle.SelectionBackColor = Color.Blue
AOP6A.Rows(e.RowIndex).DefaultCellStyle.ForeColor = Color.White
AOP6A.Rows(e.RowIndex).DefaultCellStyle.SelectionForeColor = Color.Blue
Else
AOP6A.Rows(e.RowIndex).Cells(“CheckBoxColumn”).Style.BackColor = Color.White
AOP6A.Rows(e.RowIndex).Cells(“CheckBoxColumn”).Style.SelectionBackColor = Color.White
AOP6A.Rows(e.RowIndex).DefaultCellStyle.BackColor = Color.White
AOP6A.Rows(e.RowIndex).DefaultCellStyle.SelectionBackColor = Color.White
AOP6A.Rows(e.RowIndex).DefaultCellStyle.ForeColor = Color.Black
AOP6A.Rows(e.RowIndex).DefaultCellStyle.SelectionForeColor = Color.Black
End If
AOP6A.Invalidate()
End If
End If
Try
If AOP6A.Columns(e.ColumnIndex).Name = “Colfilter” Then
Dim checkCell As DataGridViewCheckBoxCell =
CType(AOP6A.Rows(e.RowIndex).Cells(“Colfilter”),
DataGridViewCheckBoxCell)
If CType(checkCell.Value, [Boolean]) = True Then
For i As Integer = 0 To Me.AOP6A.Columns.Count - 1
AOP6A.Rows(e.RowIndex).Cells(i).Style.BackColor = Color.Blue
AOP6A.Rows(e.RowIndex).Cells(i).Style.SelectionBackColor = Color.Blue
Next
Else
For j As Integer = 0 To Me.AOP6A.Columns.Count - 1
AOP6A.Rows(e.RowIndex).Cells(j).Style.BackColor = Color.White
AOP6A.Rows(e.RowIndex).Cells(j).Style.SelectionBackColor = Color.White
Next
End If
AOP6A.Invalidate()
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub AOP6VIEW()
Dim filtersourcedatatable As DataTable = AOP6A.DataSource 'Top grid in which filter criteria is entered
Dim destdatatable As DataTable = C1AOP5.DataSource
Dim commonality As IEnumerable(Of DataRow)
Dim lastqry = From theRow In destdatatable.AsEnumerable()
Select theRow
lastqry = GetIntersection(filtersourcedatatable, lastqry) 'And operator
Dim dtclone = destdatatable.Clone()
dtclone.Clear()
For Each drow As DataRow In lastqry
dtclone.ImportRow(drow)
Next
If dtclone.Rows.Count = 0 Then
MsgBox(“No Records Found in AOP-6”)
C1AOP5.Visible = False
End If
If dtclone.Rows.Count <> 2000 Then '2000 isTotal Rows in table
TEST = 1
C1AOP5.Visible = True
Me.C1AOP5.DataSource = dtclone
Else
C1AOP5.Visible = False
End If
End Sub
Thanks,
Victor