If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Listbox- Record Select

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-13-04, 08:30
vjmehra vjmehra is offline
Registered User
 
Join Date: May 2004
Posts: 13
Listbox- Record Select

Hi,

This code works fine, but part of it is really bugging me. Basically this code changes the page to reflect the item slected in a list box, the only problem is I have to first assign:

Me.Articlelist.SelectedValue.ToString

to the text property of a label and then refer to this from the line me.position = otherwise it doesn't work. I have tried converting the string but it refuses to work and I just get an error saying 'Input string was not in a correct format'. Does anyone know why this is happening?

Public Class WebForm8

Inherits System.Web.UI.Page
Public Position As Integer


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
Me.Articlelist.AutoPostBack = True
If Me.IsPostBack Then
Me.Dsarticles = CType(Viewstate("Dsarticles"), DataSet)
Me.Dsphotos = CType(Viewstate("Dsphotos"), DataSet)
Me.Position = CType(Viewstate("Position"), Integer)
Else

Me.Daarticles.Fill(Me.Dsarticles.tblarticles)
Daphotos.SelectCommand.Parameters("@article_ID").V alue = DataBinder.Eval(Me.Dsarticles.tblarticles.DefaultV iew(Position).Row, "article_ID")
Me.Daphotos.Fill(Me.Dsphotos.tblphotos)
viewstate("Dsarticles") = Me.Dsarticles
viewstate("Dsphotos") = Me.Dsphotos
viewstate("Position") = 0
End If

Me.DataBind()

End Sub
Private Sub Page_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.DataBinding
Dim dr As DataRow
dr = Me.Dsarticles.tblarticles.DefaultView(Position).Ro w

'Me.lbArticle_Name.Text = DataBinder.Eval(dr, "Article_Name")
Me.lbarticle_text.Text = DataBinder.Eval(dr, "Article_text")
Me.lbWritten_By.Text = DataBinder.Eval(dr, "Written_By")
Me.lbarticle_date.Text = DataBinder.Eval(dr, "Article_Date")
Me.Label1.Text = Me.Articlelist.SelectedValue.ToString

End Sub

Private Sub Articlelist_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Articlelist.SelectedIndexChanged

If Me.Position <= Me.Dsarticles.tblarticles.Count - 1 Then
Me.Position = Me.Label1.Text - 1
Me.Dsphotos.Clear()
Daphotos.SelectCommand.Parameters("@article_ID").V alue = DataBinder.Eval(Me.Dsarticles.tblarticles.DefaultV iew(Position).Row, "article_ID")
Me.Daphotos.Fill(Me.Dsphotos.tblphotos)
viewstate("Dsphotos") = Me.Dsphotos
viewstate("Position") = Me.Position
Me.DataBind()
End If


End Sub

End Class
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On