0
首先,我有一個grdData在我的主頁。選擇我想和數據後去使用值不能被轉換爲「system.collections.arraylist」
Request.QueryString("id")
在該頁的另一頁我想使用
Request.QueryString("id")
再拍grdData但
Value of type 'cfeedback' cannot be converted to 'system.collections.arraylist'
在一個錯誤來了
以下是我的代碼
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim objArrayList As New ArrayList
Dim objCDBFeedback As New CDBFeedback
Dim intGuestID2 As Integer
intGuestID2 = Request.QueryString("id")
objArrayList = objCDBFeedback.getFeedBack(intGuestID2)
grdResult.DataSource = objArrayList
grdResult.DataBind()
grdResult.HeaderRow.BackColor = Drawing.Color.AliceBlue
grdResult.RowStyle.BackColor = Drawing.Color.BlanchedAlmond
grdResult.AlternatingRowStyle.BackColor = Drawing.Color.LightSalmon
grdResult.Columns(0).Visible = True
End Sub
我的功能
Public Function getFeedBack(ByVal pintGuestID1 As Integer) As CFeedback
Dim objCmd As New MySqlCommand
Dim objCn As New MySqlConnection(connectionString)
Dim objAdapter As New MySqlDataAdapter
Dim strSQL As String = ""
Dim objDs As New DataSet
Dim objDataRow As DataRow
strSQL = "SELECT * FROM tblFeedback WHERE strGuestCodeFB=" & pintGuestID1
objCmd.CommandText = strSQL
objCmd.Connection = objCn
objAdapter.SelectCommand = objCmd
objCn.Open()
objAdapter.Fill(objDs, "tblFeedback")
objDataRow = objDs.Tables("tblFeedback").Rows(0)
Dim objCFeedback As New CFeedback
objCFeedback.Feedback = objDataRow.Item("strGuestCompanyTI")
objCn.Close()
Return objCFeedback
End Function
我的班級
Public Class CFeedback
Private strGuestCodeFB As Integer
Private strFeedBackFB As String
Public Property GuestId() As String
Get
Return strGuestCodeFB
End Get
Set(ByVal value As String)
strGuestCodeFB = value
End Set
End Property
Public Property Feedback() As String
Get
Return strFeedBackFB
End Get
Set(ByVal value As String)
strFeedBackFB = value
End Set
End Property
End Class
那麼,是否有可能在一個查詢字符串一個grdData基地?
嗨competent_tech,我該放什麼在CValues中? – waterbottle 2012-01-10 09:53:35
competent_tech ..在反饋數據庫中,我想爲grdData顯示多個反饋。我如何獲得與「RequestQuerystring」具有相同strGuestCodeFB的所有反饋。 因爲現在它只顯示一個反饋,當我有3個相同的strGuestCodeFB。 – waterbottle 2012-01-10 10:11:27
還如何設置,它不會顯示grdData如果沒有在功能getFeedback找到的記錄? – waterbottle 2012-01-10 10:25:45