[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Databinding : find out what field a property is bound to

Posted on 2009-05-11
4
Medium Priority
?
281 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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 …
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

649 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