Click to See Complete Forum and Search --> : Databinding and DataList - help
PT Exorcist
May 28th, 2003, 02:40 PM
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?
hellswraith
May 28th, 2003, 02:49 PM
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.
PT Exorcist
May 28th, 2003, 03:04 PM
how do i do that thru a datareader?
hellswraith
May 28th, 2003, 03:17 PM
datalist1.DataSource = myReader
datalist1.DataBind()
hellswraith
May 28th, 2003, 03:18 PM
Just to clarify, this line:
label1.Text=<%# DataBinder.Eval(Container.DataItem, "columnName") %>
goes in the html part, not the code.
PT Exorcist
May 28th, 2003, 03:41 PM
ah after a lot of tweaking i think i did it! ty!
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.