下拉列表值重复 [英] Dropdown list values repeating

查看:63
本文介绍了下拉列表值重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用从数据库绑定的下拉列表值,我的代码

I am using dropdown list values Bound from data base my code

Public Function get_type() As String
    'get type
    If IsPostBack = False Then
        da = New OleDbDataAdapter("select distinct (type) from prod_type", con)
        da.Fill(ds, "prod_type")
        ddtype.DataSource = ds
        ddtype.DataTextField = "type"
        ddtype.DataValueField = "type"
        ddtype.DataBind()
        da.Dispose()
        ds.Dispose()
        con.Close()
    End If


我在页面load


I call this function in page load

推荐答案

按我说
只需清除DropDownList
在使用YOur加载之前
数据.可能刚好
As Per Me
Just Clear the DropDownList
Before You are Loading it With YOur
Data.May be Just Below
If IsPostBack = False Then
.......Clear Here Your DropDownlist


遵循代码
If Not isPostBack() Then
 ddtype.Items.Clear() //clear your dropdonlist before filling it
 .
 .
 .
 .
 .
EndIf



谢谢



Thanks


这篇关于下拉列表值重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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