accessing a specific cotrol from web DataGrid control.

S

Shakeel

Hello Everyone,


In web DataGrid's ItemTemplate, I've placed a asp:Hyperlink control with id
"hypfeature" within column index 3 and this column also contains some other
asp:Hyperlink controls . DataGrid is being Bounded to the DataTable which
returning some rows. I've to
write code for making asp:Hyperlink "hypfeature" visible or invisible on
the base
of "small" column of the DataTable. I've tried to write some code after
Binding
DataGid control to the DataTable object in page's load event like:


CType(Me.DataGrid.FindControl("hypfeature"), HyperLink).Visible = False

but it throws NullReferenceException.

and I also tried like this:

CType(DataGrid.Items(0).Cells(3).Controls(2), HyperLink).Visible = False

but this raise ArgumentOutOfRangeException, The "hypfeature" is in 4the
cell's 3'rd control. Even DataGrid.Items.count returning zero which means
that It has no control.

I'm not getting what's problem with this code. If some one know then Please
tell
me the right way to access control which is added in web DataGrid.


Thanks.
Shakeel Ahmad





I also tried in the ItemDataBound Event Handler of the DataGrid control
like:
 
P

Patrick Olurotimi Ige

Shakeel,
Try doing it in the ItemDataBound and if u have tried it.Try
posting your ItemDataBound event method if it isn't working.
Patrick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,619
Members
45,316
Latest member
naturesElixirCBDGummies

Latest Threads

Top