Click to See Complete Forum and Search --> : Compiler Error Message: BC30456: 'DataList1_Command' is not a member of 'ASP.sofa1_as


ABYINKUS
03-25-2009, 12:13 PM
Hi,
When creating my shopping cart I encountered a problem when running my code it read "Line 105: <asp:DataList id="DataList1" runat="server" OnSelectedIndexChanged="DataList1_SelectedIndexChanged" OnItemCommand="DataList1_Command">" please can you help, this is my source code
<%@ Page Language="VB" %>
<script runat="server">

' Insert page code here
'
Dim objDT as System.Data.DataTable
Dim objDr as System.Data.DataRow



Function GetSofas(ByVal prod_Name As String) As System.Data.IDataReader
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=E:\HTML\Furniture.mdb"
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)

Dim queryString As String = "SELECT [Products].[Prod_Name], [Products].[Prod_desc], [Products].[Prod_picture],"& _
" [Products].[Prod_price] FROM [Products] WHERE ([Products].[Prod_Name] = @Prod_N"& _
"ame)"
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dbParam_prod_Name As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
dbParam_prod_Name.ParameterName = "@Prod_Name"
dbParam_prod_Name.Value = prod_Name
dbParam_prod_Name.DbType = System.Data.DbType.[String]
dbCommand.Parameters.Add(dbParam_prod_Name)

dbConnection.Open
Dim dataReader As System.Data.IDataReader = dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

Return dataReader
End Function

Sub Page_Load

Dim temp as String=Request.QueryString("Info")

Dim temp2 as Integer = Session.Count
if (temp2<1) then
makecart()
end if


DataList1.DataSource()=GetSofas(temp)
DataList1.DataBind



End Sub

Function makeCart()
objDT = New System.Data.DataTable("Cart")
objDT.Columns.Add("Prod_No", GetType(Integer))
objDT.Columns.Add("Prod_Name", GetType(String))
objDT.Columns.Add("Prod_price", GetType(String))

Session("Cart") = objDT
End Function


Sub furniture_ItemCommand(s as object, e as DataGridCommandEventArgs)

Select (CType(e.CommandSource, LinkButton)).CommandName

Case "Cart"
Dim itemCell As TableCell

objDT=Session("Cart")

objDR = objDT.NewRow


itemCell = e.Item.Cells(1)
objDR("Prod_No") = itemCell.Text

itemCell = e.Item.Cells(2)
objDR("Prod_Name") = itemCell.Text

itemCell = e.Item.Cells(3)
objDR("Prod_price") = itemCell.Text
objDT.Rows.Add(objDR)

Session("Cart") = objDT
Me.DataList1.DataBind()

Response.Redirect("cart6.aspx")
Case Else
Response.Redirect("cart6.aspx")

End Select

End Sub

Sub DataList1_SelectedIndexChanged(sender As Object, e As EventArgs)

End Sub

</script>
<html>
<head>
<title>Aviva sofa</title>
</head>
<body>
<form runat="server">
<asp:DataList id="DataList1" runat="server" OnSelectedIndexChanged="DataList1_SelectedIndexChanged" OnItemCommand="DataList1_Command">
<ItemTemplate>
<table bgcolor="#333000" border="0" align="center">
<tr bgcolor="#808080">
<th bgcolor="#808080" colspan="2">
<asp:Label id="Pname" text='<%#Container.DataItem("Prod_Name")%>' runat="server" />
</th>
<td width="20%">
<asp:ImageButton runat="server" ImageURL='<%#Container.DataItem("Prod_picture")%>' ></asp:ImageButton>
</td>
</tr>
<tr>
<th bgcolor="#333333" colspan="2"></th>
</tr>
<tr>
<td>
<asp:Button id="basket" CommandName="cart" text="Add to basket" runat="server" />
<asp:Button id="cncl" CommandName="cancel_button" text="Cancel" runat="server" />
</td>
</tr>
</tbody>
</table>
</ItemTemplate>
</asp:DataList>
</form>
</body>
</html>

Kuriyama
03-25-2009, 02:58 PM
This is a .NET page. Ask this in the .NET forums. It's sad that you have to have someone on a forum tell you this. . . .