国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

DPC: Creating a multicolumn dropdownlist[等級:初 中]

2024-07-21 02:25:03
字體:
供稿:網(wǎng)友
國內(nèi)最大的酷站演示中心!
creating a multicolumn dropdownlist
click here to return to my article index
one of the frequently asked questions over at asplists.com is: "how do i create a multicolumn dropdownlist?". i have come up with two ways to accomplish this task.

the first technique combines the two columns in the sql query used to create the resultset and then binds the resultset to the dropdownlist. more aspalliance sql articles can be found here.

code:
    sub filldropdownsql()
    dim myconnection as sqlconnection = new sqlconnection("data source=test; user id=test; password=test; initial catalog=pubs")
    dim mycommand as sqlcommand = new sqlcommand("select pub_id + ',' + pub_name as idandname from publishers", myconnection)
    
    myconnection.open()

    dropdownlist1.datatextfield = "idandname"

    dropdownlist1.datasource = mycommand.executereader(commandbehavior.closeconnection)
        dropdownlist1.databind()
    end sub



result:
0736,new moon books 0877,binnet & hardley 1389,algodata infosystems 1622,five lakes publishing 1756,ramona publishers 9901,ggg&g 9952,scootney books 9999,lucerne publishing

the second technique combines the two columns while looping through a sqldatareader. the combination of the two columns is then programmatically added to the dropdownlist. more information on the sqldatareader can be found here.

code:
    sub filldropdowncode()
    dim myconnection as sqlconnection = new sqlconnection("data source=test; user id=test; password=test; initial catalog=pubs")
    dim mycommand as sqlcommand = new sqlcommand("select pub_id,pub_name from publishers", myconnection)
    dim mydatareader as sqldatareader

    myconnection.open()
    mydatareader = mycommand.executereader()
    
    while mydatareader.read()
        dropdownlist2.items.add(mydatareader.getstring(0) & "," & mydatareader.getstring(1))
    end while

    mydatareader.close()
    myconnection.close()
    end sub


result:

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 庆元县| 涪陵区| 泰兴市| 托克托县| 顺平县| 阳信县| 吉安县| 台安县| 沛县| 天津市| 石楼县| 东至县| 夏邑县| 民丰县| 石门县| 永平县| 拜泉县| 固原市| 咸丰县| 若羌县| 肇庆市| 思茅市| 工布江达县| 高雄县| 永修县| 宜都市| 吉木乃县| 历史| 镇江市| 临海市| 晋宁县| 陆川县| 丰顺县| 芜湖县| 云和县| 汶川县| 潞西市| 承德市| 上高县| 靖宇县| 本溪|