Make a row invisible/not be shown when string = "blabla"

  • Thread starter Thread starter Richard
  • Start date Start date
R

Richard

After printing a userlist to a Datagrid i want some names not to be shown. I
want to know how i can make a entire datagrid row invisible.

I suspect its something with the OnItemDatabound but i am kinda stuck there.
but this is basicly what i want.

if Username = "Deleted_User" then
'make entire table row invisible.
End if

I hope someone can give me the code on how i can accomplish this. Thx in
advance.

Richard
 
use this..
private void DataGrid1_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if((e.Item.FindControl("") as Label).Text == "Deleted_User")
e.Item.Visible = false;
}

Av.
 
Well, that didnt work for me. What i want is to make the entire row
invisible.

<asp:DataGrid ....... bla bla....>
<asp:BoundColumn DataField="U_Username" SortExpression="U_Username"
HeaderText="<strong>Username</strong>" />
<asp:BoundColumn DataField="A_LEVELNAAM" SortExpression="A_LEVELNAAM"
HeaderText="<strong>Level</strong>" />
<asp:BoundColumn DataField="U_Posts" SortExpression="U_Posts"
HeaderText="<strong>Posts</strong>" />
<asp:BoundColumn DataField="U_Registered_On"
SortExpression="U_Registered_On" HeaderText="<strong>Date
Registered</strong>" />
<asp:BoundColumn DataField="U_Last_Logged_In"
SortExpression="U_Last_Logged_In" HeaderText="<strong>Last Active</strong>"
/>
</columns>
</asp:DataGrid>

Whenever a username equels "Deleted_User" i would like that the entire row
would be invisible not only the username but every column.
If it's possible i'd like the example/code in VB. my C# aint good. :D

thx in advance Richard
 
well i finally finished it :D

Sub myDataGrid_ItemDataBound(Sender As Object, e As DataGridItemEventArgs)
If e.Item.ItemType <> ListItemType.Header AND e.Item.ItemType <>
ListItemType.Footer then
Dim lblUsername As Label = E.Item.FindControl("lblUsername")
If NOT lblUsername Is Nothing then
If RTrim(lblUsername.Text) = "" OR RTrim(lblUsername.Text) =
"Deleted User" Then
e.item.Visible = False
End If
End If
End If
End Sub

this my code and it worked :D thx for your help avnrao.
 
Back
Top