Solved

Databinding : find out what field a property is bound to

Posted on 2009-05-11
4
279 Views
Last Modified: 2012-05-06
Hi

I have a usercontrol with a property of Text, i am using this within a formview and binding using standard stuff

ie : Text='<%# Bind("ColumnName")%>'

now from within my usercontrol i need to know what the Text property is bound to, i dont want to have to have another property of FieldName and have to set it twice..

Thanks
0
Comment
Question by:crazyman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 13

Author Comment

by:crazyman
ID: 24352856
Ive tried using

IDataBindingsAccessor acc = this as IDataBindingsAccessor;

but its always empty...
0
 
LVL 3

Expert Comment

by:OblivionSY
ID: 24355439
I'm trying to follow what you're trying to achieve. Controls should be encapsulated and as such, why would it need to know what property it was bound to on the outside form? Not sure how to achieve what you're asking. but maybe with what you're trying to achieve can come up with a solution?
0
 
LVL 13

Author Comment

by:crazyman
ID: 24358039
Yes encapsulation is great, this however is a means to an end and the time saved and flexibility it will bring will be worth it.

I have a user control that will display a textbox wit some autocomplete beaviour etc.. (Telerik RadControls to be precise).
Now this sits inside a formview that is bound to a business object, these object are created from Telerik OpenAccess ORM and as such contain metadata about the object fields, in this case Length...

As an excersise i am trying to evaluate the possiblility of the UI auto detecting the length of varchar/string fields via the orm business objects metadata, this works great if i know the name of the field if you set it via a property but its duplication and as such i would like to either set it via only a property or via the databinding expression...

At current i have

<DIS:TextField id="Field1" runat="server" DataField="UserName" Text='<%#Bind("UserName")%>' />

If i could get away with just the property and still allow 2 way binding then great theres your encapsulation...
0
 
LVL 3

Accepted Solution

by:
OblivionSY earned 500 total points
ID: 24359821
I think I see what you are trying to do. You could bind another property? so MaxLength=...

Otherwise, in code on te databound event, you could pass in the object and handle the displaying of text there, plus then you could get the length information?

Not sure how/if possible to get back to the other data. Sorry, not hugely helpful
0

Featured Post

Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question