J
Joey Liang via DotNetMonster.com
Hi all,
I am new in asp.net, i encounter some problems in using drop down
list and datagrid. I have manage to bind the data into datagrid but i
wanted to bind the data into the datagrid accroding to the selected brand
from the drop down list. I do not have any idea how to do it. Does anyone
knows how to bind the data in to datagrid accroding to the drop down list
selected item? if there is a way would u mind paste the code or any
tutorials regarding this so that i can refer.
Here is e code i write but seemd ro have some logic error..when i select an
item in the drop down list,there is no response..Anyone knows which part of
the code that goes wrong?Thanx in advance
Private Sub ddlBrand_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ddlBrand.SelectedIndexChanged
Dim strSqlCmd As String
Dim objAdp As OleDb.OleDbDataAdapter
Dim dataTable As DataTable
Dim brand As String
brand = ddlBrand.SelectedItem.Value
strSqlCmd = "Select p.ProductID, p.ProductName,p.ProductBrand, " & _
"p.ProductImage, p.Price, p.Quantity " & _
"From Product p, CategoryProduct cp Where " & _
"p.ProductID= cp.productID " & _
"and cp.CategoryID=" & Request.QueryString.Get("CategoryID")
& _"and p.ProductBrand=" & brand
objAdp = New OleDb.OleDbDataAdapter(strSqlCmd, con)
dataTable = New DataTable
objAdp.Fill(dataTable)
dgProducts.DataSource = dataTable
dgProducts.DataBind()
End Sub
Thanx,
Joey
I am new in asp.net, i encounter some problems in using drop down
list and datagrid. I have manage to bind the data into datagrid but i
wanted to bind the data into the datagrid accroding to the selected brand
from the drop down list. I do not have any idea how to do it. Does anyone
knows how to bind the data in to datagrid accroding to the drop down list
selected item? if there is a way would u mind paste the code or any
tutorials regarding this so that i can refer.
Here is e code i write but seemd ro have some logic error..when i select an
item in the drop down list,there is no response..Anyone knows which part of
the code that goes wrong?Thanx in advance
Private Sub ddlBrand_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ddlBrand.SelectedIndexChanged
Dim strSqlCmd As String
Dim objAdp As OleDb.OleDbDataAdapter
Dim dataTable As DataTable
Dim brand As String
brand = ddlBrand.SelectedItem.Value
strSqlCmd = "Select p.ProductID, p.ProductName,p.ProductBrand, " & _
"p.ProductImage, p.Price, p.Quantity " & _
"From Product p, CategoryProduct cp Where " & _
"p.ProductID= cp.productID " & _
"and cp.CategoryID=" & Request.QueryString.Get("CategoryID")
& _"and p.ProductBrand=" & brand
objAdp = New OleDb.OleDbDataAdapter(strSqlCmd, con)
dataTable = New DataTable
objAdp.Fill(dataTable)
dgProducts.DataSource = dataTable
dgProducts.DataBind()
End Sub
Thanx,
Joey