dropdowns and gridview

having problems using multi dropdowns to populate gridview in a tabcon

Page 1 of 1

0 Replies - 1375 Views - Last Post: 11 December 2009 - 07:56 PM Rate Topic: -----

#1 pony0325  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 11-December 09

dropdowns and gridview

Posted 11 December 2009 - 07:56 PM

Imports System.Data

Partial Class PartTracking
	Inherits System.Web.UI.Page


	Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
		GetSelectedVin()

	End Sub

	Private Sub GetSelectedVin()
		Dim dvTable As DataView = CType( _
		SqlDataSource7.Select(DataSourceSelectArguments.Empty), DataView)

		'Dim dvProduct_ID As DataView = CType( _
		'SqlDataSource1.Select(DataSourceSelectArguments.Empty), DataView)
		Dim VehTracking As New VehTracking

		dvTable.RowFilter = "PART_ID = '" & lblPartID.Text & "' AND TRACE_ID LIKE " & "'%" & txtVin8.Text & "'"
		'If ddlYear.SelectedValue <> "*" Then
		'dvTable.RowFilter = dvTable.RowFilter & "NMBR_1 = '" & ddlYear.Text

		'End If
		If ddlYear.SelectedValue <> "*" Then
			dvTable.RowFilter = dvTable.RowFilter + " AND NMBR_1 = " & ddlYear.SelectedValue '"
		End If

		Try
			Dim drvRow As DataRowView = dvTable(0)

			VehTracking.PartID = drvRow("PART_ID")
			VehTracking.TraceID = drvRow("TRACE_ID")
			VehTracking.Year = drvRow("Nmbr_1")
			VehTracking.Model = drvRow("Text_11")
			VehTracking.Model = drvRow("Text_4")
			VehTracking.Exterior = drvRow("Text_9")
			VehTracking.Interior = drvRow("Text_10")

		Catch ex As Exception
			MsgBox("No records exist for selection(s)", MsgBoxStyle.OkOnly)
			Return

		End Try
	End Sub



	Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
		ddlProductId.Focus()
		If Not IsPostBack Then
			ddlProductId.DataBind()
			ddlYear.DataBind()
			ddlMake.DataBind()
			ddlModel.DataBind()
			ddlExterior.DataBind()
			ddlInterior.DataBind()

		End If
		ddlProductId.Items.Insert(0, New ListItem("MAKE SELECTION"))
		ddlYear.Items.Insert(0, New ListItem("*"))
		ddlMake.Items.Insert(0, New ListItem("*"))
		ddlModel.Items.Insert(0, New ListItem("*"))
		ddlExterior.Items.Insert(0, New ListItem("*"))
		ddlInterior.Items.Insert(0, New ListItem("*"))
	End Sub

	Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
		If e.Row.RowType = DataControlRowType.Header Then  'starts the first 10 rows 
			GridView1.Columns(1).HeaderStyle.Width = 100
		End If
		' If (e.Row.DataItemIndex = -1) Then
		'Return
		'else
		'e.Row.Attributes.Add("onmouseover", "this.style.cursor='hand';")
		'e.Row.Attributes.Add("onclick", "this.GetPostBackClientEvent(GridView1, Select$" + e.Row.RowIndex.ToString()) '")
		'End If
	End Sub

	Protected Sub ddlProductId_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlProductId.SelectedIndexChanged
		Dim dvProduct_ID As DataView = CType( _
			SqlDataSource1.Select(DataSourceSelectArguments.Empty), DataView)

		Dim prod_ID As String

		dvProduct_ID.RowFilter = "A_VALUE_1 = '" & ddlProductId.SelectedValue & "'"
		Dim drvRow As DataRowView = dvProduct_ID(0)
		Dim Product As New Product
		Product.PROFILE_ID = drvRow("Profile_ID")
		Product.A_VALUE_1 = drvRow("A_VALUE_1")
		If drvRow("A_VALUE_2") <> " " Then
			Product.A_VALUE_2 = drvRow("A_VALUE_2")
		End If
		prod_ID = Product.A_VALUE_2
		lblPartID.Text = Product.A_VALUE_2
	End Sub

	Protected Sub ddlYear_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlYear.SelectedIndexChanged
		Dim dvYear As DataView = CType( _
			SqlDataSource2.Select(DataSourceSelectArguments.Empty), DataView)

		If ddlYear.Text <> "*" Then
			dvYear.RowFilter = "A_VALUE_1 = '" & ddlYear.SelectedValue & "'"
			Dim drvRow As DataRowView = dvYear(0)
			Dim Product As New Product
			Product.PROFILE_ID = drvRow("Profile_ID")
			Product.A_VALUE_1 = drvRow("A_VALUE_1")
		End If

	End Sub

	Protected Sub ddlMake_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlMake.SelectedIndexChanged
		Dim dvMake As DataView = CType( _
			SqlDataSource3.Select(DataSourceSelectArguments.Empty), DataView)

		'Dim year As String

		If ddlMake.Text <> "*" Then

			dvMake.RowFilter = "A_VALUE_1 = '" & ddlMake.SelectedValue & "'"
			Dim drvRow As DataRowView = dvMake(0)
			Dim Product As New Product
			Product.PROFILE_ID = drvRow("Profile_ID")
			Product.A_VALUE_1 = drvRow("A_VALUE_1")

		End If

	End Sub

	Protected Sub dvResult_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles dvResult.DataBinding
		dvResult.Visible = True


	End Sub

	'Protected Sub dvResult_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles dvResult.Load
	'	GridView1.DataBind()

	'End Sub
	'Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand

	'	If e.CommandName = "Select" Then

	'		Dim index As Integer = Convert.ToInt32(e.CommandArgument)

	'		' Get the last name of the selected author from the appropriate

	'		' cell in the GridView control.

	'		Dim selectedRow As GridViewRow = GridView1.Rows(index)

	'		txtVin8.Text = selectedRow.Cells(2).Text.ToString

	'		ddlYear.SelectedValue = selectedRow.Cells(3).Text.ToString
	'		ddlMake.SelectedValue = selectedRow.Cells(4).Text.ToString
	'		ddlModel.SelectedValue = selectedRow.Cells(5).Text.ToString
	'		ddlExterior.SelectedValue = selectedRow.Cells(6).Text.ToString
	'		ddlInterior.SelectedValue = selectedRow.Cells(7).Text.ToString

	'	End If

	'End Sub

	Protected Sub ddlModel_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlModel.SelectedIndexChanged
		Dim dvModel As DataView = CType( _
				SqlDataSource4.Select(DataSourceSelectArguments.Empty), DataView)

		'Dim year As String

		If ddlModel.Text <> "*" Then

			dvModel.RowFilter = "A_VALUE_1 = '" & ddlModel.SelectedValue & "'"
			Dim drvRow As DataRowView = dvModel(0)
			Dim Product As New Product
			Product.PROFILE_ID = drvRow("Profile_ID")
			Product.A_VALUE_1 = drvRow("A_VALUE_1")

		End If
	End Sub

	Protected Sub ddlExterior_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlExterior.SelectedIndexChanged
		Dim dvExt As DataView = CType( _
			SqlDataSource5.Select(DataSourceSelectArguments.Empty), DataView)

		'Dim year As String

		If ddlExterior.Text <> "*" Then

			dvExt.RowFilter = "A_VALUE_1 = '" & ddlExterior.SelectedValue & "'"
			Dim drvRow As DataRowView = dvExt(0)
			Dim Product As New Product
			Product.PROFILE_ID = drvRow("Profile_ID")
			Product.A_VALUE_1 = drvRow("A_VALUE_1")

		End If
	End Sub

	Protected Sub ddlInterior_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlInterior.SelectedIndexChanged
		Dim dvInt As DataView = CType( _
			SqlDataSource6.Select(DataSourceSelectArguments.Empty), DataView)

		If ddlInterior.Text <> "*" Then

			dvInt.RowFilter = "A_VALUE_1 = '" & ddlInterior.SelectedValue & "'"
			Dim drvRow As DataRowView = dvInt(0)
			Dim Product As New Product
			Product.PROFILE_ID = drvRow("Profile_ID")
			Product.A_VALUE_1 = drvRow("A_VALUE_1")

		End If
	End Sub

	'Protected Sub ddOption_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddOption.SelectedIndexChanged
	'	Dim dvOpt As DataView = CType( _
	'SqlDataSource2.Select(DataSourceSelectArguments.Empty), DataView)

	'	If txtOption.Text <> "*" Then
	'		dvOpt.RowFilter = "A_VALUE_1 = '" & txtOption.SelectedValue & "'"
	'		Dim drvRow As DataRowView = dvOpt(0)
	'		Dim Product As New Product
	'		Product.PROFILE_ID = drvRow("Profile_ID")
	'		Product.A_VALUE_1 = drvRow("A_VALUE_1")
	'	End If
	'End Sub


	Protected Sub TabPanel1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabPanel1.Load

	End Sub


End Class



Is This A Good Question/Topic? 0
  • +

Page 1 of 1