0
我創建低於提要的Page_Load從數據表或字符串中獲取不同的值?
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strQuery As String = "SELECT DISTINCT setsTbl.setName, trainingTbl.t_date, userAssessmentTbl.o_id FROM userAssessmentTbl LEFT JOIN trainingTbl ON userAssessmentTbl.tt_id = trainingTbl.tt_id LEFT JOIN setsTbl ON trainingTbl.s_id = setsTbl.s_id LEFT JOIN outcomesTbl ON userAssessmentTbl.o_id = outcomesTbl.o_id WHERE UserId = @UserId ORDER BY setName, t_date DESC "
Dim cmd As New SqlCommand(strQuery)
cmd.Parameters.AddWithValue("@UserId", userString)
Dim dt As DataTable = GetData(cmd)
GridView1.DataSource = dt
GridView1.DataBind()
End Sub
一個GridView目前它輸出值的數據表:
SetName t_date o_id
name1 12.12.12 1
name2 13.07.12 1
name2 15.07.12 2
name3 16.07.12 4
name3 17.07.12 3
我想獲得下面這樣的輸出不同行我的數據表:
SetName t_date o_id
name1 12.12.12 1
name2 13.07.12 1
name3 16.07.12 4
有人可以告訴我這可以實現嗎?
爲了澄清,你真的在爲每個'SetName'尋找第一個不同的行嗎? – 2012-08-02 16:13:14
是的,這正是我所追求的 – theBo 2012-08-02 19:53:56