Click to See Complete Forum and Search --> : making a particular cell invisible in a gridview - vs 2005


vbnov
May 23rd, 2006, 11:57 AM
I have a gridview with two hyperlink columns one of which is going to display a picture and other a constant text. Based on a field value I'm supposed to hide the picture and the hyperlink which has a constant text if the field value is null.

Anybody have any ideas on how to do that.

Help is greatly appreciated. Thnx.

Note:

I did the same with the datagrid with VS 2003.
I was able to check the field value in the Itemdatabound event of the datagrid and used the code

e.item.cells(0).controls(0).visible = false

But this logic doesn't work with VS 2005.

HairyMonkeyMan
May 23rd, 2006, 12:02 PM
You should be able to do something similar in the RowDatabound event of the gridview.

Good luck

vbnov
May 23rd, 2006, 12:08 PM
Thnx, Monkeyman

I tried with the rowdatabound. It only made the header invisible.

I dont know why

HairyMonkeyMan
May 23rd, 2006, 12:13 PM
Protected Sub gv_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvFiles.RowDataBound
If (e.Row.RowType = DataControlRowType.DataRow) Then
e.Row.Cells(0).controls(0).visible = false
End If
End Sub

vbnov
May 23rd, 2006, 12:23 PM
Thanks a lot. I really really really appreciate you helping me in this. Its working but not fully. I will figure that out.

You have been always a helping hand .

such a good helper you are. Hats off to you man!

Thnx again

vbnov
May 23rd, 2006, 12:41 PM
well, I figured out what I said I would figure out. But now the problem is there are 6 records that needs to be displayed. but only 5 are being displayed.

But after i sort the grid... i can see 6 rows. why is that?