Rabu, 04 Februari 2009

Using Session and gridview data. vb 2005


IDE : VS 2005,

Hi, i was wondering if soemone could help me... I have a gridview which hold various data. When i select an item using checkbox, that item is then displayed in a listbox. The coding for that is below...


Code: Protected Sub Button7_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Dim i As Int16For i = 0 To GridView1.Rows.Count - 1




If CType(GridView1.Rows(i).FindControl("CheckBox2"), CheckBox).Checked() Then



Panel1.Visible = True

ListBox1.Items().Add("" & GridView1.DataKeys(i).Value.ToString & (" " & GridView1.Rows(i).Cells(2).Text) & (" £" & GridView1.Rows(i).Cells(3).Text))
End If



However, when i click button9 i want the previously selected data from the listbox to appear in the 'basket' form... this worked, but i wanted the select items to remain in the listbox in 'basket' form so when i go back to the main page i select more items and on top of the items previously selected. Currnently, additional items can be input but the ones previosly selected disappear. I now placed the following session (which works on a new project) but does not work on my project containing the gridview. Is there anyway i can relate the seeion to the gridview nd make it work?
Thanks.


Code: Protected Sub Button9_Click1(ByVal sender As Object, ByVal e As EventArgs)
Dim ar As ArrayList
If (Not (Session("list")) Is Nothing) Then
ar = CType(Session("list"),ArrayList)
Else
ar = New ArrayList
End If
ar.Add(ListBox1.SelectedItem)
Session("list") = ar
Response.Redirect("Basket.aspx")
End Sub

and in the 2nd form.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim ar As ArrayList = CType(Session("list"),ArrayList)
ListBox1.DataSource = ar
ListBox1.DataBind
End Sub



source :http://www.vbcity.com

-------------------------------------------------------

Trik Gambar Bergerak

Trik Gambar-dimouse

Trik hapus pwd mysql

Trik insertin to db

Trik jadi root dilinux

Trik jam-distatus-bar

Trik Koneksi-ke database

Trik Koneksi-msql-php

Trik lihat-database-mysql

Trik membahas-fungsi-else

Trik member-area