D
David C
I have a DataGrid that displays 3 columns from a list of Files in a
Directory. The first column is a HyperLink that displays the file name with
a link to another page and querystring. Below is the DataGrid and below
that is the ItemDataBound code that is not hiding the file named
"Thumbs.db". What am I doing wrong to hide that cell? p.s. I would prefer to
hide the whole row. Thanks.
David
<aspataGrid runat="server" id="articleList"
AutoGenerateColumns="False"
HeaderStyle-BackColor="Navy"
HeaderStyle-ForeColor="White"
HeaderStyle-Font-Size="15pt"
HeaderStyle-Font-Bold="True"
DataKeyField="FullName" BackColor="White"
BorderColor="#999999"
BorderStyle="None" BorderWidth="1px"
CellPadding="3" GridLines="Vertical">
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="Name"
DataTextField="Name" HeaderText="File Name"
DataNavigateUrlFormatString="ShowDocs.aspx?doc={0}"
Target="_blank" />
<asp:BoundColumn DataField="LastWriteTime"
HeaderText="Last Updated"
DataFormatString="{0:d}" >
</asp:BoundColumn>
<asp:BoundColumn DataField="Length"
HeaderText="File Size"
DataFormatString="{0:#,### bytes}" >
</asp:BoundColumn>
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black"
/>
<SelectedItemStyle BackColor="#008A8C"
Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black"
HorizontalAlign="Center" Mode="NumericPages" />
<AlternatingItemStyle BackColor="#DCDCDC" />
<ItemStyle BackColor="#EEEEEE" ForeColor="Black" />
<HeaderStyle BackColor="#000084" Font-Bold="True"
Font-Size="15pt" ForeColor="White" />
</aspataGrid>
Protected Sub articleList_ItemDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
articleList.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
Dim hlcol As HyperLinkColumn = articleList.Columns(0)
Dim value As String
value = hlcol.DataNavigateUrlFormatString.ToString()
If value = "ShowDocs.aspx?doc=Thumbs.db" Then
e.Item.Cells(0).Visible = False
End If
End If
End Sub
Directory. The first column is a HyperLink that displays the file name with
a link to another page and querystring. Below is the DataGrid and below
that is the ItemDataBound code that is not hiding the file named
"Thumbs.db". What am I doing wrong to hide that cell? p.s. I would prefer to
hide the whole row. Thanks.
David
<aspataGrid runat="server" id="articleList"
AutoGenerateColumns="False"
HeaderStyle-BackColor="Navy"
HeaderStyle-ForeColor="White"
HeaderStyle-Font-Size="15pt"
HeaderStyle-Font-Bold="True"
DataKeyField="FullName" BackColor="White"
BorderColor="#999999"
BorderStyle="None" BorderWidth="1px"
CellPadding="3" GridLines="Vertical">
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="Name"
DataTextField="Name" HeaderText="File Name"
DataNavigateUrlFormatString="ShowDocs.aspx?doc={0}"
Target="_blank" />
<asp:BoundColumn DataField="LastWriteTime"
HeaderText="Last Updated"
DataFormatString="{0:d}" >
</asp:BoundColumn>
<asp:BoundColumn DataField="Length"
HeaderText="File Size"
DataFormatString="{0:#,### bytes}" >
</asp:BoundColumn>
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black"
/>
<SelectedItemStyle BackColor="#008A8C"
Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black"
HorizontalAlign="Center" Mode="NumericPages" />
<AlternatingItemStyle BackColor="#DCDCDC" />
<ItemStyle BackColor="#EEEEEE" ForeColor="Black" />
<HeaderStyle BackColor="#000084" Font-Bold="True"
Font-Size="15pt" ForeColor="White" />
</aspataGrid>
Protected Sub articleList_ItemDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
articleList.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
Dim hlcol As HyperLinkColumn = articleList.Columns(0)
Dim value As String
value = hlcol.DataNavigateUrlFormatString.ToString()
If value = "ShowDocs.aspx?doc=Thumbs.db" Then
e.Item.Cells(0).Visible = False
End If
End If
End Sub