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
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