Monday, March 26, 2012

DetailsView and ControlID

Hello

I need to force DetailsView to expose its fields
with a TargetControlID. I add these fields to DetailsView:

BoundField bf = new BoundField();
bf.DataField = sField;
bf.HeaderText = sHeader;
myDetailsView .Fields.Add(bf);

It's necessary for the AutoCompleteExtender :

AutoCompleteExtender ace = new AutoCompleteExtender();
ace.ID = "ace" + sField;
//ace.TargetControlID = "detV$ctl" + xxxxx
ace.TargetControlID = sField;
ace.ServiceMethod = "GetCompletionList";
ace.ServicePath = "wsLkAutoComplete.asmx";
ace.MinimumPrefixLength = 2;
ace.EnableCaching = true;
ace.CompletionInterval = 300;

Any idea ? I can't find this anywhere...

Best Regards

Do you need to be doing this dynamically? If so, have you tried creating a templatefield, the adding a label to the item template of the template field, and a textbox to the edit template field. At this point you will have the textbox so you can use the TextBox1.ClientId property to get its client id. This should return the clientid from within its container.


hello, thank you for replying !

I already tried creating a templatefield, but didn't liked it...

I wanted to use the boundfield, so that it could generate the right controls by itself for the data,

and not to write the needed logic for insert-update-delete-etc.etc.

Using templatefield, would be like making it by hand...

best regards


Hi Kaliban555,

Ajax Control Toolkit's TargetControl should be a server side control. As far as I know, if you use BoundField , we cannot generate a server side control(not html code) and bind it to the Extender. BoundField is not a container indeed. So I think in this situation, TemplateField is a better choice.

I hope this help.

Best regards,

Jonathan.

No comments:

Post a Comment