Results 1 to 2 of 2

Thread: RESOLVED***Problems with asp.net

  1. #1

    Thread Starter
    Member Canibus's Avatar
    Join Date
    Jun 2003
    Location
    South Africa
    Posts
    61

    RESOLVED***Problems with asp.net

    hi!

    i have a problem with .net. i wanna know why does the
    page reload itself after i've clicked a button. & also
    how come i cant see all my data in a dropdown list.
    see code below


    While reader.Read
    'populate role datalist
    tmpRole = reader("role_descr")
    dlRoles.Items.Add(tmpRole)
    End While


    and also when i add a to datalist nothing happens


    tmpRole = dlRoles.SelectedItem.Value
    lstEmpRoles.Items.Add(tmpRole)




    thanx
    Last edited by Canibus; Jun 22nd, 2004 at 03:05 PM.
    Canibus Signs out!!

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    You will want to only populate the data for the first load...

    so...
    VB Code:
    1. Private Sub Page_Load (...
    2.  
    3.  If Not IsPostBack Then
    4.   'Load your data into your dropdowns
    5.  End If
    6.  
    7. End Sub

    As far as not seeing all your data in your datalist, you are probably suffering from object conversion errors, but without Option Strict enabled, you have become unaware of them.

    OR

    Preferably, you should simply set the datasource to your reader, and call DataBind on the datalist.

    VB Code:
    1. Dim dr As System.Data.SqlClient.SqlDataReader = SqlCommand1.ExecuteReader(CommandBehavior.CloseConnection)
    2.  
    3. DataList1.DataSource = dr
    4. DataList1.DataBind()
    5. dr.Close()

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width