Click here to Skip to main content
15,917,174 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionDoubt in Dataview filter options Pin
jayarajmrj10-Sep-07 0:43
jayarajmrj10-Sep-07 0:43 
AnswerRe: Doubt in Dataview filter options Pin
John-ph10-Sep-07 1:45
John-ph10-Sep-07 1:45 
Questionpopup window Pin
saravanan0510-Sep-07 0:43
saravanan0510-Sep-07 0:43 
AnswerRe: popup window Pin
John-ph10-Sep-07 1:13
John-ph10-Sep-07 1:13 
AnswerRe: popup window Pin
N a v a n e e t h10-Sep-07 1:51
N a v a n e e t h10-Sep-07 1:51 
QuestionHow to insert HTML string (with tags) in word and display as html Pin
here2learn10-Sep-07 0:33
here2learn10-Sep-07 0:33 
Questionhow do i store news articles? Pin
marvc19-Sep-07 23:46
marvc19-Sep-07 23:46 
Questionprevious page is error but still work.. Pin
hardyyanto9-Sep-07 23:39
hardyyanto9-Sep-07 23:39 
hello all....,

i have a error, but it's can working.. i have post this in forum 4 thread and codeproject 3 thread, but they give answer can not working... so, pls... help...
i have 2 page like default.aspx and cart.aspx.
this is my code:

default.aspx


<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>





<title>Untitled Page




<asp:sqldatasource id="SqlDataSource1" runat="server" connectionstring="<%$ ConnectionStrings:GAMESConnectionString %>"
="" selectcommand="SELECT * FROM [items]">


<asp:repeater id="Repeater1" runat="server" datasourceid="SqlDataSource1">
<headertemplate>


<itemtemplate>
<asp:label id="kode" runat="server" text="<%#Eval("Kode") %>">
<asp:label id="name" runat="server" text="<%#Eval("Name") %>">

<asp:label id="cost" runat="server" text="<%#Eval("cost","{0:n}") %>">

<asp:textbox id="total" text="1" runat="server" width="24px">
<asp:button id="addtocart" runat="server" commandname="buy" text="add to cart" postbackurl="~/cart.aspx?from=default">

<footertemplate>









default.aspx.vb

Partial Class _Default
Inherits System.Web.UI.Page
Private kode As String = ""
Private name As String = ""
Private total As Integer = 0
Private cost As Double = 0
Public Function dataList() As ArrayList
Dim itemselecting As ArrayList = New ArrayList
itemselecting.Add(kode)
itemselecting.Add(name)
itemselecting.Add(total)
itemselecting.Add(cost)
dataList = itemselecting
End Function

Protected Sub Repeater1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles Repeater1.ItemCommand
kode = CType(Repeater1.Items(e.Item.ItemIndex).FindControl("kode"), Label).Text
name = CType(Repeater1.Items(e.Item.ItemIndex).FindControl("name"), Label).Text
total = CInt(CType(Repeater1.Items(e.Item.ItemIndex).FindControl("total"), TextBox).Text)
cost = CType(Repeater1.Items(e.Item.ItemIndex).FindControl("cost"), Label).Text

End Sub
End Class



cart.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="cart.aspx.vb" Inherits="cart" %>





<title>Untitled Page








<asp:repeater id="Repeater1" runat="server">
<itemtemplate>


kode name total cost subtotal
<asp:label id="label1" runat="server" text="<%#DataBinder.eval(Container.DataItem,"Kode") %>"> <asp:label id="label2" runat="server" text="<%#DataBinder.eval(Container.DataItem,"Name") %>"> <asp:textbox id="txttotal" runat="server" text="<%#DataBinder.eval(Container.DataItem,"total") %>"
="" width="20px">
<asp:label id="label3" runat="server" text="<%#DataBinder.eval(Container.DataItem,"cost") %>"> <asp:label id="label4" runat="server" text="<%#DataBinder.eval(Container.DataItem,"subTotal") %>">
grand total: <asp:label id="total" runat="server" text="0"> <asp:label id="subtotal" runat="server" text="0">


<asp:button id="Button1" runat="server" text="update">












cart.aspx.vb


Partial Class cart
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not PreviousPage Is Nothing AndAlso PreviousPage.IsCrossPagePostBack Then
Dim itembuy As Integer
Dim itemselecting As ArrayList = New ArrayList
If (Request.QueryString("from") = "default") Then
itemselecting = CType(Me.PreviousPage, _default).datalist()
End If
itembuy = Session("Itembuy")
If Not checksameitem(itemselecting(0)) Then
Session("Kode_" & itembuy) = itemselecting(0)
Session("Name_" & itembuy) = itemselecting(1)
Session("total_" & itembuy) = itemselecting(2)
Session("cost_" & itembuy) = itemselecting(3)
Session("subtotal_" & itembuy) = itemselecting(2) * itemselecting(3)
itembuy += 1
Session("itembuy") = itembuy
End If
displayData()
End If
If Not IsPostBack Then
Me.displayData()
End If
End Sub
Private Sub displayData()
Dim a As ArrayList = New ArrayList()
Dim itembuy As Integer
Dim i As Integer
Dim totalItem As Integer = 0
Dim totalcost As Double = 0
itembuy = Session("itembuy")
For i = 0 To itembuy - 1
a.Add(New DataKasir(Session("Kode_" & i), Session("Name_" & i), Session("total_" & i), Session("cost_" & i), Session("subtotal_" & i)))
totalItem += Session("total_" & i)
totalcost += Session("subTotal_" & i)
Next
Me.total.Text = totalItem
Me.subtotal.Text = Format(totalcost, "#,##0.00")
Repeater1.DataSource = a
Repeater1.DataBind()
End Sub
Private Function checksameitem(ByVal kode As String) As Boolean
Dim totalItem As Integer = Session("itembuy")
Dim i As Integer
For i = 0 To totalItem
If (Session("Kode_" & i) = kode) Then
checksameitem = True
End If
Next
End Function
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim totItem As Integer = Repeater1.Items.Count
Dim total As Integer
Dim cost As Double
Dim i As Integer
For i = 0 To totItem - 1
total = IIf(CType(Repeater1.Items(i).FindControl("txttotal"), TextBox).Text = "", 0, _
CType(Repeater1.Items(i).FindControl("txttotal"), TextBox).Text)
cost = CDbl(Session("cost_" & i))
Session("total_" & i) = total
Session("subtotal_" & i) = total * cost
Next
displayData()
End Sub

End Class
Public Class DataKasir
Private myKode As String
Private myName As String
Private mytotal As Integer
Private mycost As Double
Private mysubtotal As Double
Public Sub New(ByVal nKode As String, ByVal nName As String, ByVal ntotal As Integer, ByVal ncost As Double, ByVal nsubTotal As Double)
Me.myKode = nKode
Me.myName = nName
Me.mytotal = ntotal
Me.mycost = ncost
Me.mysubtotal = nsubTotal
End Sub
Public ReadOnly Property Kode() As String
Get
Return myKode
End Get
End Property
Public ReadOnly Property Name() As String
Get
Return myName
End Get
End Property
Public ReadOnly Property total() As Integer
Get
Return mytotal
End Get
End Property
Public ReadOnly Property cost() As Double
Get
Return mycost
End Get
End Property
Public ReadOnly Property subTotal() As Double
Get
Return mysubtotal
End Get
End Property
End Class



my error is in the cart.aspx.vb like the command:

If (Request.QueryString("from") = "default") Then
itemselecting = CType(Me.PreviousPage, _default).datalist()

the error is" type _default is not defined" .. i have no idea to solve this... it can work properly.. but this error can active if there is a some error or warning in the page.
if page not have any errors or warning, this error can not active,but sometimes can error..
so i want to this error resolved, i want _default can be defined...

plz... helppp.....

thx......
AnswerRe: previous page is error but still work.. Pin
John-ph10-Sep-07 0:37
John-ph10-Sep-07 0:37 
GeneralRe: previous page is error but still work.. Pin
hardyyanto10-Sep-07 5:03
hardyyanto10-Sep-07 5:03 
Questionexcel not working uniformly across machines with same os Pin
S Palip9-Sep-07 23:11
S Palip9-Sep-07 23:11 
Questionmake procedure to check balance > or < totalcost Pin
hardyyanto9-Sep-07 23:03
hardyyanto9-Sep-07 23:03 
AnswerRe: make procedure to check balance > or < totalcost Pin
John-ph10-Sep-07 1:27
John-ph10-Sep-07 1:27 
GeneralRe: make procedure to check balance > or < totalcost Pin
hardyyanto10-Sep-07 5:27
hardyyanto10-Sep-07 5:27 
QuestionUnmatched records from DataTables Pin
jayarajmrj9-Sep-07 22:55
jayarajmrj9-Sep-07 22:55 
AnswerRe: Unmatched records from DataTables Pin
PrakashBhaskar10-Sep-07 0:54
PrakashBhaskar10-Sep-07 0:54 
AnswerRe: Unmatched records from DataTables Pin
John-ph10-Sep-07 1:03
John-ph10-Sep-07 1:03 
Question[Message Deleted] Pin
Sreekumar P P9-Sep-07 22:41
Sreekumar P P9-Sep-07 22:41 
AnswerRe: MOSS 2007 Workflow Pin
John-ph9-Sep-07 22:55
John-ph9-Sep-07 22:55 
AnswerRe: MOSS 2007 Workflow Pin
Pete O'Hanlon9-Sep-07 23:00
mvePete O'Hanlon9-Sep-07 23:00 
Questionget image properties with javascript [modified] Pin
morteza579-Sep-07 22:25
morteza579-Sep-07 22:25 
AnswerRe: get image properties with javascript Pin
morteza579-Sep-07 23:29
morteza579-Sep-07 23:29 
QuestionIFRAME through ASP.NET with C# Pin
.NET- India 9-Sep-07 21:59
.NET- India 9-Sep-07 21:59 
AnswerRe: IFRAME through ASP.NET with C# Pin
John-ph9-Sep-07 22:48
John-ph9-Sep-07 22:48 
QuestionHOw to display the button id Pin
Mri1a9-Sep-07 21:55
Mri1a9-Sep-07 21:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.