C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Vb.net code to display images and titles of Searched sale items by Price


Posted Date: 29 Aug 2008    Resource Type: Code Snippets    Category: ASP.NET WebForms

Posted By: Swaminathan       Member Level: Gold
Rating:     Points: 10



Following code can be used to display images and titles of searched sale items by price. Viz. by entering any price and clicking search button will display the images and titles of those sale items which cost around specified price range viz. Specified range + or -2. For ex:If you type 35 then, all sale items whose cost is between 33 and 37 will be displayed.

All table rows are generated during run time and corresponding data is fetched
from the database and displayed.


 
Imports System.Data
Imports System.Data.OleDb
Partial Class SearchResults
Inherits System.Web.UI.Page
Public y As String

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


Label1.Text = ""
Dim sc As New OleDbConnection
Dim scm1 As New OleDbCommand
y = Request.QueryString("b")
Dim a As String = y - 2
Dim b As String = y + 2
Dim dap1 As New OleDbDataAdapter
Dim ds1 As New DataSet
Dim i As Integer


sc.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("SiteSqlServer")
scm1.CommandText = "select * from ITEM_MASTER where ITEM_PRICE BETWEEN " & CType(a, Integer) & " AND " & CType(b, Integer) & ""
scm1.Connection = sc
dap1.SelectCommand = scm1
dap1.Fill(ds1)

Dim tmpRowIdx As Integer = 0

For i = 0 To ds1.Tables(0).Rows.Count - 1


tmpRowIdx = i \ 3
If (tmpRowIdx + 1 > Table1.Rows.Count) Then
Dim tmpRow As New TableRow
Table1.Rows.Add(tmpRow)
End If

addCellToTable(tmpRowIdx, ds1.Tables(0).Rows(i).Item("ITEM_IMAGE"), ds1.Tables(0).Rows(i).Item("ITEM_DESCRIPTION"), ds1.Tables(0).Rows(i).Item("ITEM_ID"))


Next




If ds1.Tables(0).Rows.Count = 0 Then
Label1.Text = ""
Label1.Text = "No results found"



End If

End Sub
Function FormatURL(ByVal strArgument) As String
Return (strArgument)
End Function
Private Sub addCellToTable(ByVal pRowIdx As Integer, ByVal pImageUrl As String, ByVal pDescription As String, ByVal pItemId As String)
Dim tmpCell As New TableCell
Dim tmpImage As New ImageButton
Dim tmpDesc As New Label

tmpImage.ImageUrl = pImageUrl
tmpImage.Style.Add("Align", "Center")
tmpImage.OnClientClick = "window.open('BuyButtonPage1.aspx?a=" & pItemId & "', 'myWindow')" 'A013"

tmpDesc.Text = pDescription
tmpDesc.Width = "200"
tmpDesc.Font.Bold = True
tmpDesc.Font.Size = "12"
tmpDesc.Font.Name = "Arial"
tmpDesc.ForeColor = Drawing.Color.DarkGreen
tmpDesc.Style.Add("Align", "Center")

tmpCell.Controls.Add(tmpImage)
tmpCell.Controls.Add(tmpDesc)
tmpCell.Width = "200"
tmpCell.HorizontalAlign = HorizontalAlign.Center

Table1.Rows(pRowIdx).Cells.Add(tmpCell)
End Sub

End Class





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Vb.net code to display images and titles of Searched sale items by Price  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: On Before Unload
Previous Resource: Saving file retreived from Fileupload on server
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET WebForms


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

it help desk

Contact Us    Privacy Policy    Terms Of Use