嗨我已經發布了這個問題,但dint得到答案,請幫助我通過下拉列表顯示gridview。下面是一個沒有必要的,因爲filter
有你已經在查詢的末尾添加相同的值在vb.net編輯code.How從asp.net使用vb.net下拉列表中顯示gridview
Private Sub BindGridView()
Dim filter As String = ""
If ddlOwnerDepartment.SelectedValue <> "" Then
filter = filter & " AND OwnerDepartment ='" & ddlOwnerDepartment.SelectedValue & "'"
End If
Dim table1 As DataTable = New DataTable("Details")
table1.Columns.Add("ReferenceNo")
table1.Columns.Add("Title")
table1.Columns.Add("Counterparty")
table1.Columns.Add("OwnerDepartment")
table1.Columns.Add("Status")
table1.Columns.Add("CreatedBy")
table1.Columns.Add("CreatedOn")
table1.Columns.Add("link")
table1.Rows.Clear()
Dim conSQL As New SqlConnection(conStrDRS)
conSQL.Open()
Dim cmdSQL As SqlCommand = New SqlCommand("SELECT Title, ReferenceNo,OwnerDepartment,CreatedBy,CreatedOn,Status,Counterparty " & _
" FROM [dbo].[Registration]" & filter)
cmdSQL.Connection = conSQL
Dim adptSQL As New SqlClient.SqlDataAdapter(cmdSQL)
Dim myDataSet As New DataSet()
adptSQL.Fill(myDataSet)
conSQL.Close()
gvDetails.DataSource = myDataSet.Tables(0) 'dvAlert
gvDetails.DataBind()
End Sub
Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
BindGridView()
End Sub
問題是什麼,你所面對?爲什麼你在'OwnerDepartment'上應用兩次過濾器?另外,您應該使用參數化查詢來避免SQL注入攻擊。 –
hello avi是什麼問題?有什麼錯誤?例外請與具體的問題來 – user1140237
當我點擊搜索沒有可用的數據。 – avi