国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 姚安县| 依兰县| 周至县| 建水县| 历史| 泸溪县| 霍城县| 苍山县| 南汇区| 化州市| 东山县| 利川市| 南江县| 连山| 长武县| 富民县| 滕州市| 栾城县| 定西市| 化州市| 鹤庆县| 尖扎县| 永靖县| 三都| 庆城县| 北京市| 长泰县| 浦城县| 松原市| 旌德县| 浮梁县| 澄迈县| 旺苍县| 田林县| 宜州市| 西贡区| 绥芬河市| 咸阳市| 南木林县| 弋阳县| 揭阳市|