Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Databinding a checkboxlist
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00835569
Message ID:
00835886
Views:
20
Welcome to ASP.Net's half assed databinding <g>... it's one way only as you found out.

For a way to build VFP like proper two way databinding and more take a look at this article:

http://www.west-wind.com/articles.asp
Implementing two way databinding with ASP.Net


+++ Rick ---



>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")
>' oDataObj is a class that handles getting data from SQL
>
>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.
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform