Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Finding control in GridView

Have you ever wanted to get the control property in your code-behind but you can't "see" it? Ok, here is the way to find it.

In this case I am using GridView control which is bind to datasource and has, for example a template field which has custom control let's say Label1 and I want to get it's property "Text".

 

Dim LabelText As Label = CType(GridView.FindControl("Label1"), Label)

LabelText.Text = "This is the test text for the Label1 control in grid view"

That's it!

P.S.

If you have any questions ask

 

No Comments