I'm preparing to do an .NET exam and I came across this question. I have been breaking my head over this but I can't figure it out :s I tried all of this but didn't come up with a clear answer...

You are implementing an ASP.NET application that uses data-bound GridView controls in multiple pages. You add JavaScript code to periodically update specific types of data items in these GridView controls. You need to ensure that the JavaScript code can locate the HTML elements created for each row in these GridView controls, without needing to be changed if the controls are moved from one page to another. What should you do?

A. Replace the GridView control with a ListView control.

B. Set the ClientIDMode attribute to Predictable in the web.config file.

C. Set the ClientIDRowSuffix attribute of each unique GridView control to a different value.

D. Set the @ OutputCache directives VaryByControl attribute to the ID of the GridView control."

This is what I came up with:

A. Since the structure of the GridView and the ListView is similar and since they generate the same sort of IDs, I scratched this one.

B. I tested this, but it doesn't seem to affect the IDs :s I think I would have to apply more settings than just this one to get some effect.

C. This makes me wonder about what the question really says, this makes all rows unique. But is that what is supposed to happen, since you're not supposed to change code?

D. This is for caching, so has nothing to do with the question.

Can someone clear this out for me? Any ideas?

有帮助吗?

解决方案

The question tells that ther can be data-bound GridView controls in multiple pages and also, if one gridview control is removed from one page to another page then it should work without any conflict with the already present gridview control.

so for th at we need to set GridView.ClientIDRowSuffix Property. So the answer is C.

Check this MSDN link.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top