Internet is growing Every Seconds :: Industry is growing Every Year

Monday, June 28, 2004

Dot net Overloads Function Fill_Combo_Relation :

Public Overloads Function Fill_Combo_Relation :

This method is used to fill the given combo box with the data, from the specified table, which is based upon the selected Value of Master Combo box.
It accepts 4 arguments namely, DetailDataTable, masterCombo, ReleteFieldName and Detailcombo.
DetailDataTable – is the table where the data is to be retrieved.
MasterCombo – is the combo box from which the selected data is retrieved to match the rows from the DetailDataTable.
RelateFieldName – is the fieldname, which is used to set the filter condition.
Detailcombo – is the combo box that is to be filled with the selected data.
This method returns the data view object.



Public Overloads Function Fill_Combo_Relation(ByRef DetailDataTable As DataTable, ByRef MasterCombo As ComboBox, ByVal RelatefieldName As String, ByRef DetailCombo As ComboBox)
Try
Dim dv_view As New DataView(DetailDataTable)
dv_view.RowStateFilter = DataViewRowState.OriginalRows
dv_view.RowFilter = RelatefieldName & " = " & MasterCombo.SelectedValue.ToString
'MsgBox("Master ID : " & MasterCombo.SelectedValue.ToString)
If dv_view.Count > 0 Then
DetailCombo.DataSource = dv_view
DetailCombo.DisplayMember = dv_view.Table.Columns(1).ToString
DetailCombo.ValueMember = dv_view.Table.Columns(0).ToString
'DetailCombo.Focus()
Else
Dim dv As New DataView(tbl_Not_Available)
dv.RowFilter = "ID = '0'"
DetailCombo.DataSource = dv
DetailCombo.DisplayMember = dv.Table.Columns(1).ToString
DetailCombo.ValueMember = dv.Table.Columns(0).ToString
End If
Catch
End Try
End Function
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

Public Overloads Function Fill_Combo_Relation(ByRef DetailDataTable As DataTable, ByRef MasterCombo As ComboBox, ByVal RelatefieldName1 As String, ByVal RelatefieldName2 As String, ByVal Relatefieldvalue2 As Integer, ByRef DetailCombo As ComboBox)
Try
Dim dv_view As New DataView(DetailDataTable)
dv_view.RowStateFilter = DataViewRowState.OriginalRows
dv_view.RowFilter = RelatefieldName1 & " = " & MasterCombo.SelectedValue.ToString & " and " & RelatefieldName2 & " = " & Relatefieldvalue2
'MsgBox("Master ID : " & MasterCombo.SelectedValue.ToString)
If dv_view.Count > 0 Then
DetailCombo.DataSource = dv_view
DetailCombo.DisplayMember = dv_view.Table.Columns(1).ToString
DetailCombo.ValueMember = dv_view.Table.Columns(0).ToString
'DetailCombo.Focus()
Else
Dim dv As New DataView(tbl_Not_Available)
dv.RowFilter = "ID = '0'"
DetailCombo.DataSource = dv
DetailCombo.DisplayMember = dv.Table.Columns(1).ToString
DetailCombo.ValueMember = dv.Table.Columns(0).ToString
End If
Catch
End Try
End Function