【发布时间】:2011-06-02 11:09:38
【问题描述】:
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
If e.CommandName = "Hold" Then
Dim gvRow As GridViewRow = CType(CType(sender, Control).Parent.Parent, GridViewRow)
Dim index As Integer = gvRow.RowIndex
Dim myRow As GridViewRow = GridView1.Rows(index)
'Find the checkbox
Dim lab5 As Label = DirectCast(myRow.FindControl("Label5"), Label)
Dim label2 As Label = DirectCast(myRow.FindControl("Label2"), Label)
Dim label4 As Label = DirectCast(myRow.FindControl("Label4"), Label)
Dim label22 As Label = DirectCast(myRow.FindControl("Label22"), Label)
Me.Response.Redirect("Select_seats.aspx?s_no=" & label22.Text.ToString & "&" & "journey=" & Label6.Text & "&" & "seater=" & label4.Text & "&" & "sleeper=" & label2.Text & "&" & "service=" & lab5.Text.ToString)
End If
End Sub
此代码给出错误:
在这一行
im gvRow As GridViewRow = CType(CType(sender, Control).Parent.Parent, GridViewRow)
错误:
无法将“ASP.vendors_select_service_aspx”类型的对象转换为“System.Web.UI.WebControls.GridViewRow”类型。
【问题讨论】:
-
为什么是
& "&" &"<string>"而不是& "&<string>"?为什么你在lab5.Text上调用ToString而没有别的?为什么What's用小写的w拼写z而不是s并且没有撇号? -
上面已经提到了代码,,,,,
-
@user559800 来自
.aspx的代码是@bAN 需要看到的。 -
ASP 部分.. 与 gridview.. 你只提到了 VB 中的代码
-
为什么要遍历 Grid 中的所有行?因此,您在第一行重定向,而不是在导致“Hold-Command”的行。