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