If you read the article, you'll see that the method is embedded in the framework and on the
ListView the method is public.I don't know exactly why we made the decisions we did my not exposing that method on the other controls, but FindControl is an abused function and people don't know how to use it properly. Wouldn't
you rather have an api to get the values (because that is what you really want), rather than the thing that contains the values? Supposed your using bound fields and turned HtmlEncode and other formatting options on for your cell, do you want
to use FindControl and have to figure out what sequence of methods to call to get the unformatted data back? Why not call
ExtractValuesFromCell which knows how to do that?
I'm not saying don't use FindControl its just not the silver bullet that fixes all problems.
You are correct [:)] I think it's funny because it's the first time ever I see someone using this method. While everyone is using FindControl as a standard.
I'm going to keep this in mind next time I need to get the value out of datacontrol. Thank you.
davidfowl
Contributor
2683 Points
608 Posts
Microsoft
Getting Data out of your DataControls
Dec 19, 2008 12:57 AM|LINK
Please read this blog post before you start using FindControl or go digging into the control tree.
http://weblogs.asp.net/davidfowler/archive/2008/12/12/getting-your-data-out-of-the-data-controls.aspx
Senior SDE, ASP.NET Team, Microsoft
MisterFantas...
Participant
1335 Points
380 Posts
Re: Getting Data out of your DataControls
Dec 26, 2008 10:13 AM|LINK
Hi,
Is this very helpful in handling user controls ?
Please let me know the advantages of this.
Thanks,
Thani
rami_nassar
Contributor
3608 Points
828 Posts
Re: Getting Data out of your DataControls
Dec 27, 2008 09:27 PM|LINK
it's the only way to get data from controls inside data controls
Nassar, Rami (MCP, MCTS, MCPD)
My Blog || E-Mail
Don't forget to click "Mark as Answer" on the post that helped you.
davidfowl
Contributor
2683 Points
608 Posts
Microsoft
Re: Getting Data out of your DataControls
Dec 28, 2008 01:09 AM|LINK
what is?
Senior SDE, ASP.NET Team, Microsoft
Nemesis116
Contributor
4667 Points
927 Posts
Re: Getting Data out of your DataControls
Dec 28, 2008 11:23 AM|LINK
Visit my blog
davidfowl
Contributor
2683 Points
608 Posts
Microsoft
Re: Getting Data out of your DataControls
Dec 28, 2008 03:34 PM|LINK
If you read the article, you'll see that the method is embedded in the framework and on the ListView the method is public.I don't know exactly why we made the decisions we did my not exposing that method on the other controls, but FindControl is an abused function and people don't know how to use it properly. Wouldn't you rather have an api to get the values (because that is what you really want), rather than the thing that contains the values? Supposed your using bound fields and turned HtmlEncode and other formatting options on for your cell, do you want to use FindControl and have to figure out what sequence of methods to call to get the unformatted data back? Why not call ExtractValuesFromCell which knows how to do that?
I'm not saying don't use FindControl its just not the silver bullet that fixes all problems.
Hope this helps
Senior SDE, ASP.NET Team, Microsoft
Nemesis116
Contributor
4667 Points
927 Posts
Re: Getting Data out of your DataControls
Dec 28, 2008 10:53 PM|LINK
You are correct [:)] I think it's funny because it's the first time ever I see someone using this method. While everyone is using FindControl as a standard.
I'm going to keep this in mind next time I need to get the value out of datacontrol. Thank you.
Visit my blog
rami_nassar
Contributor
3608 Points
828 Posts
Re: Getting Data out of your DataControls
Dec 31, 2008 10:18 AM|LINK
its like this
CType(yourDataControl.FindControl("yourControlID"), yourControlType).putTheProperityHereNassar, Rami (MCP, MCTS, MCPD)
My Blog || E-Mail
Don't forget to click "Mark as Answer" on the post that helped you.
davidfowl
Contributor
2683 Points
608 Posts
Microsoft
Re: Getting Data out of your DataControls
Dec 31, 2008 03:30 PM|LINK
Why use FindControl if you don't have to?
Senior SDE, ASP.NET Team, Microsoft
rami_nassar
Contributor
3608 Points
828 Posts
Re: Getting Data out of your DataControls
Dec 31, 2008 06:20 PM|LINK
david, why you say that.. can you explain your idea??
Nassar, Rami (MCP, MCTS, MCPD)
My Blog || E-Mail
Don't forget to click "Mark as Answer" on the post that helped you.