dropdownlist的滚动条不起作用&如何将下拉列表绑定到数据库 [英] scrollbar of dropdownlist doesn't work & how to bind dropdownlist to database

查看:47
本文介绍了dropdownlist的滚动条不起作用&如何将下拉列表绑定到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好.

我已经通过ASP.net 4设计了一个Webform并使用Sqlserver 2008r2设计了一个Webform,在我的表单中有一个包含国家/地区名称的下拉列表.我的要求:

1-为了获得更好的性能,我不认为在ASp.net中添加项目(国家名称)(下拉列表项目集合)或向

将它们绑定到我的数据库(国家/地区表)?

2-当我将dropdownlist放入表单并运行解决方案时,dropdownlist没有滚动条吗?我该如何激活它?

如果我使用HTML Select选项,则不知道如何将其绑定到数据库..

hello.

i have designed a webform by ASP.net 4 & using Sqlserver 2008r2 , in my form there is a Dropdownlist that includes names of countries .my qeustions:

1- for the better performance i don''t whether is this good to add items (name of countries ) in ASp.net (dropdownlist item collection) or to

bind them to my database , table of Country?

2- when i put dropdownlist in my form and run the solution there is no scroll bar for dropdownlist ? how can i activate it?

if i use HTML Select option , i don''t know how to bind it to database..

推荐答案

//将数据绑定到html中的dropdownlist />
//To bind the data to dropdownlist in html
<select name="" id="" style="WIDTH: 200px" class="clsListBox">
                        <% call FillCombo() %>
                    </select>


Sub FillCombo()
SqlCon.open()
Dim sqlcmd As SqlCommand = New SqlCommand("SP Name", sqlcon)
        sqlcmd.CommandType = CommandType.StoredProcedure

        Dim da As SqlDataAdapter = New SqlDataAdapter(sqlcmd)

        Dim dr As SqlDataReader

        dr = sqlcmd.ExecuteReader()
        Dim intComboID As Integer = 0
               While dr.Read()

            Response.Write("<option value='" & intComboID & "'dr.Item("Name") & "</option>")
                       intComboID = intComboID + 1

        End While
         dr.Close()
        dr = Nothing
        sqlcon.Close()
End Sub


这篇关于dropdownlist的滚动条不起作用&amp;如何将下拉列表绑定到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆