views:

223

answers:

1

I have a form with BoundFields in it and I need to get ClientID(s) for control(s) associated with each BoundField I have in the form. How can I do it?

UPD: I do not have control id. All I have is bound field which can not have an id.

UPD2: I'm trying to write a code like this:

public IDictionary<BoundField, string> GetCliendIDs(FormView formView)
{
    // How to find Client IDs for controls which were created for BoundFields
}
+2  A: 

Try this:

yourForm.FindControl("yourControl").ClientID.ToString();

Where "yourcontrol" is the id of the control in your form. You can find this value by opening the aspx page in source mode and look at the ID value of the control.

Also, you could access the boundfield if you know the location of them in the form control, example:

yourform.Controls[0].ClientID //first control 
yourform.Controls[1].ClientID //second control 
Ricardo
disagree... my answer provided more details and a proper formatted code example. In addition, you edited your answer to include the details my answer provided... :)
Ricardo
in my case does this mean that id of BoundField will work?
Artem
@Artem maybe, please add some of your code to the question or tell us more of what you are trying to accomplish so we can give you a more detailed answer. There might be a better way of doing what you are trying to do
Ricardo
I updated description.
Artem
@Artem Added another solution to my original answer above..
Ricardo
+1 deleted and my own answer.
Dead account