页面中有一个dropdownlist,绑定了一个表,显示表中一字段数据,现在想利用dropdownlist中显示的数据做为查询条件,click后,查询后得到的数据显示在datagrid中。可是怎么取出其值呢,老大们帮忙看目的地,以下是我的代码!
sub search_Click(sender as object , e as eventargs)
dim ds as dataset=new dataset
dim conn as oledbconnection
conn=new oledbconnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&server.mappath("/qkglxt/data/data.mdb"))
dim mycommand as oledbDataAdapter
dim flage as string="'" & dropdownlist.SelectedItem.Value & "'"
mycommand=new oledbDataAdapter("select * from expert where e_realm='"+flage+"' order by id desc",conn)
conn.open()
mycommand.fill(ds)
mydatagrid.datasource=new dataview(ds.tables(0))
mydatagrid.databind()
end sub
我将 dim flage as string="'" & dropdownlist.SelectedItem.Value & "'"
换成 dim flage as string="社科"
在e_realm字段中"社科"就全部在datagrid中显示出来了。
还有换成 dim flage as string=" & dropdownlist.Text & "也一样显示不出。
各位大侠,帮我把把脉吧!到底怎样将dropdownlist的值取出来做为查询条件呢!
sub search_Click(sender as object , e as eventargs)
dim ds as dataset=new dataset
dim conn as oledbconnection
conn=new oledbconnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&server.mappath("/qkglxt/data/data.mdb"))
dim mycommand as oledbDataAdapter
dim flage as string="'" & dropdownlist.SelectedItem.Value & "'"
mycommand=new oledbDataAdapter("select * from expert where e_realm='"+flage+"' order by id desc",conn)
conn.open()
mycommand.fill(ds)
mydatagrid.datasource=new dataview(ds.tables(0))
mydatagrid.databind()
end sub
我将 dim flage as string="'" & dropdownlist.SelectedItem.Value & "'"
换成 dim flage as string="社科"
在e_realm字段中"社科"就全部在datagrid中显示出来了。
还有换成 dim flage as string=" & dropdownlist.Text & "也一样显示不出。
各位大侠,帮我把把脉吧!到底怎样将dropdownlist的值取出来做为查询条件呢!
dim flage as string=dropdownlist.SelectedItem.Value
dim ds as dataset=new dataset
dim conn as oledbconnection
conn=new oledbconnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&server.mappath("/qkglxt/data/data.mdb"))
dim mycommand as oledbDataAdapter
dim flage as string=dlHTLB.SelectedItem.Value
mycommand=new oledbDataAdapter("select * from expert where e_realm='"+flage+"' order by id desc",conn)
conn.open()
mycommand.fill(ds)
mydatagrid.datasource=new dataview(ds.tables(0))
mydatagrid.databind()
end sub
dim fla as string=dlHTDJ.SelectedItem.Value mycommand=new oledbDataAdapter("select * from expert where e_realm='"+flage+"' and e_zhiwu='"+fla+"' order by id desc",conn) conn.open()