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
}
Artem
  • 7,275
  • 15
  • 57
  • 97

1 Answers1

2

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 Sanchez
  • 6,079
  • 3
  • 24
  • 31
  • 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 Sanchez Jan 26 '10 at 21:09
  • @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 Sanchez Jan 26 '10 at 21:30