开发者

ASP.NET Databinding A grid as a selection list

Context: I have a Query that returns a list of availables[choices]. I have an entity that has a list of [values]. I want to give the user a grid with the [choices], and depending on what [choices] are checked/selected, I would like to have those [value] of those [choices] assigned to the [entity]'s [values].

That is a fairly standard request, but my question is this: Is it possible to do this type of databinding declaratively? That is, can I do this databinding with a combination of only datasource contro开发者_C百科ls and binding expressions? How would you define a binding expression/data source that would allow a list of values to be bound to the selected item values from a grid bound to a different list without using event handlers and manually extracting the values?


Can you outer join the two queries so that you get something like:

select c.id, c.item, decode(s.id,null,'N','Y') selected
  from color c, selections s
 where c.id=s.id (+)  

Please forgive the Oracle syntax, OJ & decode() however you need. :)

ID    Item     Selected
--    -----    --------
1     Blue     N
2     Red      Y
3     Green    Y

Then, databind the selected property to that new selected column.

UPDATE:

sSQL = "select c.id, c.name, case c.id "
for each e as entity in entitycollection
  sSQL &= "when " & e.id & " then 'Y' "
next
sSQL &= " else 'N' end selected "
sSQL &= "from color"

Naturally, you'd do this from a StringBuilder, not these concatenations, but you get the idea. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜