Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
svicky9
Posting Yak Master
232 Posts |
Posted - 2006-03-30 : 11:04:38
|
Hi Guys I am new to the ASP.NETMy Code:Imports System.Data.SqlClientImports System.DataPublic Class PriceCheck Inherits System.Web.UI.Page#Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() End Sub Protected WithEvents Label1 As System.Web.UI.WebControls.Label Protected WithEvents txtSearchFor As System.Web.UI.WebControls.TextBox Protected WithEvents btnSearch As System.Web.UI.WebControls.Button Protected WithEvents grdProducts As System.Web.UI.WebControls.DataGrid 'NOTE: The following placeholder declaration is required by the Web Form Designer. 'Do not delete or move it. Private designerPlaceholderDeclaration As System.Object Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub#End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here End Sub Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click ' Connect to the database Dim connection As New SqlConnection(Global.DbString) connection.Open() ' Retreive the items... Dim sql As String = _ "SELECT productname, unitprice, unitsinstock FROM products " & _ "WHERE productname LIKE '%" & Me.txtSearchFor.Text & "%'" Dim command As New SqlCommand(sql, connection) Dim reader As SqlDataReader = command.ExecuteReader() ' Bind the DataGrid to the SqlDataReader grdProducts.DataSource = reader grdProducts.DataBind() ' Close the SqlDataReader and release the SqlCommand object reader.Close() command.Dispose() ' Close the database connection connection.Close() End Sub Public Function IsInStock(ByVal quantity As Integer) As Boolean If quantity > 0 Then Return True Else Return False End If End Function Public Function GetInStockString(ByVal quantity As Integer) As String Return GetInStockString(IsInStock(quantity)) End Function Public Function GetInStockString(ByVal inStock As Boolean) As String If inStock = True Then Return "Yes" Else Return "No" End If End FunctionEnd ClassError:BC30002: Type 'PriceCheck' is not defined.Line 27: <asp:TemplateColumn HeaderText="In Stock">Line 28: <ItemTemplate>Line 29: <asp:Label id=lblInstock runat="server" Text='<%# Ctype(Page,PriceCheck).GetInStockString(Container.DataItem("unitsinstock")) %>'>Line 30: </asp:Label>Line 31: </ItemTemplate>What should be the problem???Vic |
|
svicky9
Posting Yak Master
232 Posts |
Posted - 2006-03-30 : 11:45:46
|
Hi guysI solved it!!! I did not include the appropriate inherit function statement<%@ Page Language="vb" AutoEventWireup="false" Codebehind="PriceCheck.aspx.vb" Inherits="MyWebsite.PriceCheck"%>ThanksVic |
 |
|
|
|
|