In order to present a changeable list of options on a page, I am trying to use the CheckBoxList control which can be dynamically populated from a table. However, I can't seem to figure out what to do with the choices the user makes, since the CBL "looses" it's data source. Perhaps I'm misunderstanding what "databinding" means in .Net?
The control gets populated like so:
dim DT as DataTable = oDataObj.LoadDataTable("select * from cTable")
cblFoo.DataSource = DT
cblFoo.DataTextField = "cOptionName"
cblFoo.DataValueField = "lSelected"
cblFoo.DataBind()
The control populates, no worries. Then the user makes their selections and saves. What I need to be able to do is for each item, pass the primary key (stored in the datatable) plus whether the item was selected or not back to a SQL SP that will handle the update.
However, when I get to the point where I do the save, the cblFoo.Datasource property is set to Nothing. Somewhere the data source gets dumped/disconnected/otherwise becomes nonavailable.
Huh? Perhaps I slept thru that lecture, Perfesser, but doesn't "databind" imply some degree of permanent association between the data source and the control? Or is this another case of MS redefining terminology on unsuspecting developers? (OK, sorry, setting RANT off now). Seriously, although I think I can kludge it by hoping the DataTextField value stays unique, I'd prefer not to and use the record PK instead.
Dan LeClair
www.cyberwombat.comSET RANT ON - The Wombat BlogLife isn’t a morality contest and purity makes a poor shield. - J. Peter MulhernDisclaimer: The comments made here are only my OPINIONS on various aspects of VFP, SQL Server, VS.NET, systems development, or life in general, and my OPINIONS should not be construed to be the authoritative word on any subject. No warranties or degrees of veracity are expressed or implied. Void where prohibited. Side effects may included dizziness, spontaneous combustion, or unexplainable cravings for dark beer. Wash with like colors only, serve immediately for best flavor.