Cannot set datagrid Text attribute ????

G

Guest

Dear all,

I have a datagrid which is bind to a databse table.
One field of that table contains a filename.

What I ma trying to do is to display the content of a cell to be an icon
when the database field is not empty. In addition a direct link to the file
will be done.

Follow is my Datagrid structure for that column:
==============================
<asp:HyperLinkColumn Text="Default" HeaderText="File"
DataNavigateUrlField="DOC_LINK" DataNavigateUrlFormatString="{0}"
Target="_blank">
</asp:HyperLinkColumn>

I have then place code in the ItemDataBound event as below in order to
control appearance of cells before they are displayed.

==========>
If (e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem) Then
Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)

If IsNothing(drv.Row("DOC_LINK")) Or TypeOf
(drv.Row("DOC_LINK")) Is System.DBNull Then
'FileLink = CType(drv.Row("DOC_LINK"), String).ToString
e.Item.Cells(6).Text = String.Empty
Else
e.Item.Cells(6).Text = "<img border=0 src=file.gif>"
End If
End If

Doing this , it does not affect at all the Text attribute of my datagrid
column and the default Text get still displayed.

Then if I replace the line above with :
e.Item.Cells(6).BackColor = Color.Cyan

At this time the cell backcolor is properly set according to the database
field.

How can I affect the Text attribute, whaterver I do does not cjange it ????

THnak for your help

regards
serge
 
P

Patrick.O.Ige

serge try using template columns in your datagrid and use a control with an
ID
Use findcontrol to get the ID of the control in the itemtemplate in the
OnItemDatabound
And then check and do whatever you want to do
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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top