例如:
1.有两个表:用户主表A、个人爱好表B(B表是A表的附属表,即单个用户可能选一个爱好,也可能选多个爱好)2.在单个用户浏览页面,如何根据该用户在B表的记录数来动态绑定页面的“个人爱好”DropDownList复选框呢?请教应该用什么方法可以实现?

解决方案 »

  1.   

    抱歉,没说清楚,举个例子吧。厂商表A:
     csid   csname
     编码     名称证照表B
     zzid   zzname
     编码      名称厂商证照表C(因为一个厂商可能对应多个证照,所以单建一个表)
      csid    zzid
     厂商编码 证照编码现在作了一个显示单个厂商的页面,在这个页面显示出了厂商的基本信息(来自A表)、全部证照信息(来自B表,而且用CheckBoxList复选框来显示全部证照),现在问题是如何根据这个厂商证照表C的查询结果,将拥有的证照复选框Selected=True,没有的仍为False,如何实现?不知道说清楚了没
      

  2.   

    单个爱好可以绑定,多爱好的话dropdownlist怎么显示?
      

  3.   

    参考一下这个,就明白了
    Private Sub RadioButtonList1_SelectedIndexChanged(sender As Object, e As System.EventArgs)
       Dim chk As ListItem
       For Each chk In  Me.CheckBoxList1.Items
          chk.Selected = False
       Next chk
       Dim SecondTypeID As String = ""
       Dim con As SqlConnection = DB.CreateCon()
       con.Open()
       Dim cmd As New SqlCommand("select SecondTypeID from  LabSedType  where UserID='" + Me.RadioButtonList1.SelectedValue + "'", con)
       Dim sdr As SqlDataReader = cmd.ExecuteReader()
       While sdr.Read()
          SecondTypeID = sdr.GetInt32(0).ToString()
          Dim chk As ListItem
          For Each chk In  Me.CheckBoxList1.Items
             
             If chk.Value = SecondTypeID Then
                chk.Selected = True
             End If
          Next chk
       End While 
       sdr.Close()
       con.Close()
    End Sub
      

  4.   

    @_@ 从数据库把个人爱好抓出来绑到dll上就行了啊