السلام عليكم ورحمة الله وبركاته
واجهت مشكلة في عرض البيانات في gridView عن طريق كتابة code البحث وليس عن طريق wizard
لا أدري هل هذا الكود خطأ ، أم أن هناك مشكلة أخرى ،،
وهل بالإمكان عرض بيانات مع وجود شروط(and/or) باستخدام ال wizard ???
هذا هو الكود
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
Dim selectsql As String
selectsql = "select * from cars where type=@type and state=@state"
Dim con As New SqlConnection(connectionstring)
Dim cmd As New SqlCommand(selectsql, con)
Dim reader As SqlDataReader
cmd.Parameters.AddWithValue("@type", DropDownList1.Text)
cmd.Parameters.AddWithValue("@state", "available")
Try
con.Open()
reader = cmd.ExecuteReader()
reader.Read()
Me.GridView1.DataSource = reader
Me.GridView1.DataBind()
reader.Close()
Catch er As Exception
MsgBox(er.Message)
Finally
con.Close()
End Try
end subعند التنفيذ يعطيني في الصفحة الرسالة التالية :
The DataSourceID of 'GridView1' must be the ID of a control of type IDataSource. A control with ID 'SqlDataSource2' could not be found.





