ComboBox1.datasouce=dt倉(cāng)庫(kù)數(shù)據(jù)表
創(chuàng)新互聯(lián)擁有網(wǎng)站維護(hù)技術(shù)和項(xiàng)目管理團(tuán)隊(duì),建立的售前、實(shí)施和售后服務(wù)體系,為客戶提供定制化的成都做網(wǎng)站、網(wǎng)站建設(shè)、網(wǎng)站維護(hù)、服務(wù)器主機(jī)托管解決方案。為客戶網(wǎng)站安全和日常運(yùn)維提供整體管家式外包優(yōu)質(zhì)服務(wù)。我們的網(wǎng)站維護(hù)服務(wù)覆蓋集團(tuán)企業(yè)、上市公司、外企網(wǎng)站、商城網(wǎng)站開發(fā)、政府網(wǎng)站等各類型客戶群體,為全球1000多家企業(yè)提供全方位網(wǎng)站維護(hù)、服務(wù)器維護(hù)解決方案。
ComboBox1.displaymembers="倉(cāng)庫(kù)名稱"
ComboBox1.valuemembers=“倉(cāng)庫(kù)代碼”
選擇后,可以獲?。篊omboBox1.selectvalue,比如,選擇1號(hào)倉(cāng)庫(kù),那么,對(duì)應(yīng)的代碼就是1,當(dāng)然,這個(gè)根據(jù)你倉(cāng)庫(kù)表結(jié)構(gòu)而定
在ComboBox1的selectindexchangge事件中,進(jìn)行處理
sql可以這么寫:"select * from 貨位數(shù)據(jù)表 where 倉(cāng)庫(kù)編號(hào)='+ComboBox1.selectvalue.tostring()+"'"
將運(yùn)行后的獲得的數(shù)據(jù)源同上方法再給予ComboBox2
您好!
1.ddlname為dropdownlist的ID值
2.dropdownlist綁定sql語句為
select * from tb where name = '"+ddlname.SelectedValue.ToString()+""
3.點(diǎn)擊dropdownlist下拉扭時(shí),改變ddlname.SelectedValue.ToString()的值,就可以篩選數(shù)據(jù)了。
Dim myDataset As New DataSet
Dim myBindingSource As New BindingSource
Private Function CreatDataAdapter(ByVal myConn As OleDbConnection, ByVal SQLstr As String, ByVal Connstr As String) As OleDbDataAdapter
Dim adapter As New OleDbDataAdapter
Dim mySelectCommand As OleDbCommand
adapter.SelectCommand = New OleDbCommand(SQLstr, myConn)
Dim cb As OleDbCommandBuilder = New OleDbCommandBuilder(adapter)
Return adapter
End Function
Private Sub Build_DGV(ByVal SQLstr, ByVal ConnStr)
myDataset.Reset()
Dim myConn As New OleDbConnection(ConnStr)
CreatDataAdapter(myConn, SQLstr , ConnStr).Fill(myDataset)
myBindingSource.DataSource = myDataset.Tables(0)
DataGridView1.DataSource = myBindingSource
myConn.Close()
myConn.Dispose()
End Sub
在按鈕事件里調(diào)用Build_DGV(),不同的sql語句在DataGridView1里出不同的數(shù)據(jù),控制sql語句的where條件就能篩選數(shù)據(jù)了。
另外,你還可以用myDataset.Tables(0).DefaultView.RowFilter(filetecause)
Sub?Find(ByRef?Obj?As?DataGridView,?Optional?ByVal?value?As?String?=?Nothing,?Optional?ByVal?cellIndex?As?Integer?=?1)
For?Each?i?As?DataGridViewRow?In?DataGridView1.Rows
If?value?Is?Nothing?OrElse?value?=?""?Then
i.Visible?=?True
Else
Try
If?i.Cells(cellIndex).Value?IsNot?Nothing?Then?i.Visible?=?i.Cells(cellIndex).Value?=?value
Catch?ex?As?Exception
End?Try
End?If
Next
End?Sub
Find(DataGridView1, "張三",1)