1

私は Datagridview を持っています。値は sql datatable から取得され、そのうちの 1 つは Datagridview データバインド イベントで満たされます。

If e.Row.RowType = DataControlRowType.DataRow Then
    Dim dt As New DataTable
    Dim Ct As Integer
    Dim rspn As Integer
    Dim textrspn As String
    Dim RefNo As Label = CType(e.Row.FindControl("lblRefNo"), Label)
    If CPayment.Revstatus(RefNo.Text, Ct, rspn, textrspn) Then
        CType(e.Row.FindControl("lblRevResp"), Label).Text = textrspn.ToString
    End If
End If

今、上記のコードから得られた datagridview の値を調べたいと思います。私はすでに次のようなコードを挿入しています:

 If DropDownList1.SelectedIndex = 1 Then
                    If Ct = 1 Then
                        CType(e.Row.FindControl("lblRevResp"), Label).Text = textrspn.ToString
                    Else
                        e.Row.Visible = False
                    End If

                ElseIf DropDownList1.SelectedIndex = 2 Then
                    If Ct = 0 Then
                        CType(e.Row.FindControl("lblRevResp"), Label).Text = textrspn.ToString
                    Else
                        e.Row.Visible = False
                    End If
                ElseIf DropDownList1.SelectedIndex = 0 Then
                    CType(e.Row.FindControl("lblRevResp"), Label).Text = textrspn.ToString
                End If

それは機能しますが、行を非表示にするなどのトリッキーなことをします。より良い解決策はありますか?

4

1 に答える 1

1

実際にDatagridview列の値を検索して表示することができます

exを使用したフィルタリング。以下は、対応する値と変数を変更しただけです

Dim sql As String = "SELECT * FROM tblOfficeEquipmentProfile WHERE OE_ID  LIKE + '%'"
        sqlconn.Open()
        sCommand = New SqlCommand(sql, sqlconn)
        sAdapter = New SqlDataAdapter(sCommand)
        sBuilder = New SqlCommandBuilder(sAdapter)
        sDs = New DataSet
        sAdapter.Fill(sDs, "tblOfficeEquipmentProfile")
        sTable = sDs.Tables("tblOfficeEquipmentProfile")
        sqlconn.Close()
        DataGrid1.DataSource = sDs.Tables("tblOfficeEquipmentProfile")
于 2013-06-03T07:33:33.957 に答える