简体   繁体   中英

How do I perform an action on a gridview column only if it exists?

I have a gridview which is in a usercontrol on a page. The gridview displays data based on whatever the calling page tells it to, which may or may not include certain columns.

I want to tell the gridview how to format the columns if they're present on the page, but I also need it to ignore all the formatting if the column doesn't exist.. I already know how to format them, so I guess I just need a method to determine if they're there, and where they are in the gridview.

It sounds like you need to be creating everything dynamically in your code-behind to achieve this kind of granularity. This should help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM