Results 1 to 6 of 6

Thread: Databinding and DataList - help

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    Databinding and DataList - help

    well i have a datalist that has a label inside..now i want that label to get its .Text property from a table that i have in my mssql database using databinding...how can i achieve this?
    \m/\m/

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Code:
    label1.Text=<%# DataBinder.Eval(Container.DataItem, "columnName") %>
    That is assuming you are getting a dataset, datareader, or datatable as the source for the datalist. You substitute the columnName for the actual columns text you want.
    Last edited by hellswraith; May 28th, 2003 at 02:55 PM.

  3. #3

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    how do i do that thru a datareader?
    \m/\m/

  4. #4
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    datalist1.DataSource = myReader
    datalist1.DataBind()

  5. #5
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Just to clarify, this line:
    Code:
    label1.Text=<%# DataBinder.Eval(Container.DataItem, "columnName") %>
    goes in the html part, not the code.

  6. #6

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    ah after a lot of tweaking i think i did it! ty!
    \m/\m/

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