Two DataGrids in One Page

rex028

Well-known member
Joined
Nov 18, 2004
Messages
50
Programming Experience
Beginner
now i have two dataGrids : dg1 and dg2 in one Windows Form

i want dg1 to display table_1 and dg2 display table_2

can i achieve this with One DataAdapter only ????

if i can use one DataAdapter only ...

how can i achieve it !!

please help !!! it is quite urgent for me !!
 
Sure, just programatically set the adapters selectcommand.
I.E. : adapter1.selectcommand = "selection query"
 
my dataadapter look like this:
VB.NET:
 	 Public Function SearchDataSet(ByVal strSQL As String) As DataSet
		SetConnectString()
		'Initialize DataAdapter with SQL and connection string
		mobjDA = New OleDb.OleDbDataAdapter(strSQL, strConnect)
		mobjCB = New OleDb.OleDbCommandBuilder(mobjDA)
		objDS.Clear()
 
		'Fill in DataSet
		Try
			mobjDA.Fill(objDS)
			SearchDataSet = objDS 'Return dataset
		Catch ex As Exception
			str = "Error in SearchDataSet. Error No. " & Err.Number & " : " & Err.Description
			GetErrorMessage(str)
			Exit Function
		End Try
	End Function

it is fixed ... i have to use it ... but i can modify it ...
but how can i modify it enable me to show two datagrid with different data in the same time in the same windows form ???
 
VB.NET:
 Private Sub GetItemDetails()

		objDS.Clear()

		objDS = objUser.Search_tblUser("Select * from tbl_ITEM where Item_Type = '" & cboPOItemType.Text & "'")

		Try
			dgPOproductinfo.DataSource = objDS.Tables(0)
		Catch ex As Exception

		End Try
	End Sub

VB.NET:
  Private Sub GetPoDetails()
		objDS.Clear()
		objDS = objUser.Search_tblUser(" SELECT  p.* , s.Supplier_ID, s.Supplier_Name FROM tbl_SUPPLIER s, tbl_PURCHASE p where (p.PO_ID = '" & txtPOID.Text & "') and (p.Supplier_ID = s.Supplier_ID ) ")
		Try
			If objDS.Tables(0).Rows.Count <= 0 Then
				MsgBox("Record Not Found")
			End If
			If objDS.Tables(0).Rows.Count > 0 Then
				ts1.MappingName = objDS.Tables(0).ToString
				With tc1
					.HeaderText = "Item No."
					.MappingName = "Item_No"
					.Width = 60
				End With
				With tc2
					.HeaderText = "Item Price"
					.MappingName = "Item_Price"
					.Width = 60
				End With
				With tc3
					.HeaderText = "Item Quantity"
					.MappingName = "Item_Quantity"
					.Width = 80
				End With
				ts1.GridColumnStyles.Add(tc1)
				ts1.GridColumnStyles.Add(tc2)
				ts1.GridColumnStyles.Add(tc3)
				dgPOrderItems.TableStyles.Add(ts1)
				dgPOrderItems.DataSource = objDS.Tables(0).DefaultView

				With objDS.Tables(0)
					txtPOBranchID.Text = objFormat.FormatString(.Rows(0).Item("Branch_ID"))
					txtPOID.Text = objFormat.FormatString(.Rows(0).Item("PO_ID"))
					txtPOItemNo.Text = objFormat.FormatString(.Rows(0).Item("Item_No"))
					txtPOItemQua.Text = objFormat.FormatString(.Rows(0).Item("Item_Quantity"))
					txtPOItemPrice.Text = objFormat.FormatString(.Rows(0).Item("Item_Price"))
					txtPODay.Text = objFormat.FormatString(.Rows(0).Item("Order_Date").Day.ToString)
					txtPOMonth.Text = objFormat.FormatString(.Rows(0).Item("Order_Date").Month.ToString)
					txtPOYear.Text = objFormat.FormatString(.Rows(0).Item("Order_Date").Year.ToString)
					txtPOModifitedDate.Text = objFormat.FormatString(.Rows(0).Item("Modified_Date"))
					txtPOModifitedBy.Text = objFormat.FormatString(.Rows(0).Item("Modified_By"))
					txtPOSupplierID.Text = objFormat.FormatString(.Rows(0).Item("s.Supplier_ID"))
					txtPOsuppliername.Text = objFormat.FormatString(.Rows(0).Item("Supplier_Name"))

				End With
			End If
		Catch ex As Exception
		End Try
	End Sub

i have used different select statement ..
but when one Datagrid change .. another follows .... !!!
 
COOL !!
you are so COOL !

and then ... how can i pass the data from one to one ???
this is a really major problem i have !! :'-(
 
Back
Top