Results 1 to 5 of 5

Thread: Filling A Datagrid On Another Form . . .

Threaded View

  1. #1

    Thread Starter
    Lively Member milkmood's Avatar
    Join Date
    Mar 2005
    Location
    Forests of Delta Halo
    Posts
    109

    Question Filling A Datagrid On Another Form . . .

    Hey all,

    I have a dataset of search results that I want to put into a datagrid on another form, then allow the user to select one row and fill in textboxes on the main form with that row's data.

    Here's what I have so far...this is the code on the main form for my search button. It works fine filling in the textboxes from the dataset on the form this button is on, I just need to know how to populate the datagrid(grdCustSearch) in the other form(frmCustSearch) with the first two columns of dss:

    VB Code:
    1. Private Sub btnCustomerSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCustomerSearch.Click
    2.         Dim srch As String
    3.         Dim sqls As String
    4.         Dim dss As New DataSet
    5.         Dim das As New Odbc.OdbcDataAdapter
    6.         Dim csreturn As New frmCustSearch
    7.  
    8.         Try
    9.             srch = txtCustomerSearch.Text
    10.             sqls = "SELECT * FROM customer WHERE LOWER(customername) LIKE '%" & srch.ToLower & "%' ORDER BY customername ASC;"
    11.             das = New Odbc.OdbcDataAdapter(sqls, con)
    12.             dss.Clear()
    13.             das.Fill(dss, "customer")
    14.  
    15.                'Something to fill the datagrid in the other form goes here; I just KNOW it!
    16.  
    17.  
    18.                'These were used to fill in the textboxes on the current form
    19.                'And they still will be, but from the dataset on the new form
    20.             'txtCustomerName.Text = dss.Tables("customer").Rows(0).Item(0)
    21.             'txtCustomerNumber.Text = dss.Tables("customer").Rows(0).Item(1)
    22.  
    23.             csreturn.ShowDialog()
    24.             csreturn.Dispose()
    25.  
    26.         Catch ex As Exception
    27.             MessageBox.Show("No record found", "No Record", MessageBoxButtons.OK)
    28.         End Try
    29.  
    30.     End Sub
    Thanks in advance.
    CP
    Last edited by milkmood; May 23rd, 2005 at 05:43 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width