473,396 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Cannot set datagrid Text attribute ????

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
Apr 11 '06 #1
1 1261
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

"serge calderara" <se************@discussions.microsoft.com> wrote in
message news:7A**********************************@microsof t.com...
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

Apr 12 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mike Speak | last post by:
On my page_load, I am populating a Datagrid through the normal manner (which works) before attempting to pick out the items in one column to use in another part of my page. This is all within...
2
by: localhost | last post by:
When I go into Edit mode on a datagrid, I would like to add a single column to the edited row and display a hyperlink. If I use the code below, I get a delete linkbutton in every row, when I only...
2
by: Marty McDonald | last post by:
When setting certain datagrid properties with the IDE (as in the property window), they don't seem to take effect. For instance, Font Name. So I have to set these via code-behind at the cell...
3
by: Janaka | last post by:
Hi All, I'm having a problem with Page Output caching on a page that contains a DataGrid. Basically the page pulls up some data for sales information from the DB. Some of this has to be...
0
by: bill yeager | last post by:
I have a datalist displaying parent information and a datagrid presenting child information. The data is being rendered just fine. The datagrid has template columns on it that I cannot gain access...
2
by: Lerp | last post by:
Hi all, I have several template columns in my datagrid, is there an attribute that sets the fore color for the text in these buttons...I would like them to be black instead of the default link...
5
by: Brian Henry | last post by:
I have a messaging application that has a data grid with information like an email list would have (from, subject, time sent, size) but the subject could be very long in theory, and then it would...
5
by: Lyners | last post by:
What I want to do, I have a datagrid with totals in one column and a text field in the next. What I would like to provide is a way for the user to click on an arrow under/next to the total amount...
13
by: Lyners | last post by:
I have a web page writen in ASP.NET that contains some javascript so that when a user presses a button, or edits a certain field in a datagrid, another cell in the datagrid is filled with a value....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.