开发者

Connect UserControl to a Datasource (ObjectDataSource in my case)

I'm trying to find a way to Databind a usercontrol to a datasource (an ObjectDataSource in my case) like in the case below :

<uc1:AutoComplete ID="autoComCities" runat="server" DataSourceID="objCitiesDS" DataValueField="Id" DataTextField="Name" />

I've try to find some good exemple with our lil' friend Google and I still ain't find anything concret. Someone can show me or give me good links on how I could do this. I mean, about how to handle it in my usercontrol ;o)

Thanks!

Edit

Note that in my case, it's not a Dropdownlist or any Bindable control in my usercontrol, its a normal asp.Net Textbox with some custom jQuery so when user type in the textbox, it shows "possibilities" under the textbox. So, I want to get values from th开发者_StackOverflow社区e DataSrouce and put it into HTML so jQuery can Handles values and shows it to user.


You can't just use the ObjectDataSource, there is a lot of plumbing to get that to work. You can pass the ID and call the Select() method to perform the selection manually and then get the values from the data and render them out. You'll have to use reflection or DataBinder.GetPropertyValue method to extract the individual field values within each record.

HTH.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜