Re: Cannot set datagrid Text attribute ????



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" <sergecalderara@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:7A407BB2-291E-419C-B554-7725F1690B3A@xxxxxxxxxxxxxxxx
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


.



Relevant Pages

  • RE: How to put different cell type in the same DataGrid column?
    ... DataGridColumnStyle paints the cell contents internally. ... checkboxes, DataGridBoolColumn.Paint method draws the dummy CheckBoxes. ... Whenever the end user clicked certain cell in DataGrid, ... method will show an internal Control and move to that cell rectangle. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Datagrid table cells and rows -- Changing width
    ... You don't have full control over column width. ... Then the browser will set the width of this ... Setting cell width for every row separately, as in your example, doesn't ... > I have a datagrid that contains 3 colums. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Display 1 data row as multiple datagrid rows
    ... I have written a custom control before, ... isn't intuitively obvious how to easily extend the Microsoft datagrid to do ... horizontal scrolling is consider bad design. ... wrap too and allow for sorting of any column it's practical to sort on. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: ASP.NET limitations?!?
    ... displaying 1000s of rows in a single DataGrid may not be the best way ... the control as well, ... "Milan Todorovic" wrote in message ... When I understand the reason ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Adding dummy item to DropDownList in a DataGrid
    ... creates a new DdropDownList control called list, it is not in a DataGrid, it ... control that is inside a DataGrid. ... Dim cell As TableCell = CType ...
    (microsoft.public.dotnet.framework.aspnet)