代码???--------------------------------
AspNetPager 免费分页控件2.0版发布,新增Url分布功能,欢迎下载使用:http://www.webdiyer.com

解决方案 »

  1.   

    '初始化DropDownList
        While reader.Read()
        DropList_productid.Items.Add(New ListItem(reader("name"), reader ("ProductID")))
        End While为什么不这样写呢?
    DropList_productid.DataSource=myreader
    DropList_productid.DataTextField="name"
    DropList_productid.DataValueField="name"
    DropList_productid.DataBind();
      

  2.   

    ameng_2002(wader) :
          你的方法我试过了,也是一样的问题。当我把你的DropList_productid.DataValueField="name"这行代码注释掉后,
    在DropDownList的SelectedIndexChanged事件中就可以取出当前选项的文本值:
            planid.Text = DropList_planid.SelectedItem.Text 我把我自己的代码改成如下也没问题了:
      While reader.Read()
           DropList_planid.Items.Add(New ListItem(reader("plan_id")))
      End While
    我不明白的是为什么多加了一个value就不行了呢?但是当我在DropDownList的
    SelectedIndexChanged事件中取出当前的value值也没问题,就是有时候取不出正确的
    Text值。
        实在郁闷,请指点!
      

  3.   

    我的代码如下,麻烦大家帮忙分析一下:
    sub page_load(.....)
    if not ispostback then  
          Dim conn As System.Data.SqlClient.SqlConnection
            Dim cmd As System.Data.SqlClient.SqlCommand
            Dim reader As System.Data.SqlClient.SqlDataReader
            Dim dd = ConfigurationSettings.AppSettings("strConn")
            conn = New System.Data.SqlClient.SqlConnection(dd)
            conn.Open()
            cmd = New System.Data.SqlClient.SqlCommand("select plan_id,productid from plan_stock", conn)
            reader = cmd.ExecuteReader()       While reader.Read()
               DropList_planid.Items.Add(New ListItem(reader("plan_id"),reader("productid")))
           End While
    end if
       ..........
    end subPrivate Sub DropList_planid_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropList_planid.SelectedIndexChanged
            planid.Text = DropList_planid.SelectedItem.Text
    End Sub
      

  4.   

    将DropDownList的AutoPostBack设为true了吗?
      

  5.   

    肯定将AutoPostBack设成true了呀。
    要不然当改变DropDownList的选项时,就没有任何反映了
      

  6.   

    把Page_Load中所有的代码包括在  if (!Page.IsPostBack){}中
    例如:如果你的
            Page_Load()
            {
                  ... //表示有代码
             }那么改写成
           Page_Load()
            {
                 if (!Page.IsPostBack)
        {
                     ... //表示有代码
                 }
             }
      

  7.   

    把Add方法中的value去掉就可以了,如下:
    While reader.Read()
           DropList_planid.Items.Add(New ListItem(reader("plan_id")))
    End While
      

  8.   

    看不出有什么错啊,不会是你的plan_id有重复值吧?--------------------------------
    AspNetPager 免费分页控件2.0版发布,新增Url分布功能,欢迎下载使用:http://www.webdiyer.com