Button in datagrid display if it is a member

tiffany

Well-known member
Joined
Aug 7, 2005
Messages
57
Programming Experience
1-3
Hi all. I had a question for datagrid. If the system determines that it is a member, a push button will display in the datgrid. How to code it to make this happen?

thanks
tiffany
 
Hi it me again. I had produce some codes for my previous qns but it doesn't work, can anyone help me with it?

Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand
Dim btn As System.Web.UI.WebControls.Button = CType(e.CommandSource, System.Web.UI.WebControls.Button)
Dim userName As System.Web.UI.WebControls.TemplateColumn = CType(e.CommandSource, System.Web.UI.WebControls.TemplateColumn)
Dim name As String = user_name.Text

If name = userName.HeaderText Then
btn.Visible = True
Else
btn.Visible = False
End If
End Sub


This is the code for the button to be visible if the message is post by the member itself. It appear no error but the button doesn't display for the codes above. The button in datagrid , i had choose a push button and set the visible to false.

thankx
tiffany
 
Hi, the above codes cannot work so i come out with new codes.

Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound

Dim btn As System.Web.UI.WebControls.LinkButton = CType(e.Item.FindControl("LinkButton"), LinkButton)

Dim name As String = user_name.Text

'calling this method from db to select the member name and compare between user_name.text and databound in the datagrid
Dim uID As String
ds = bl.selectID(uID)
DataGrid1.DataSource = ds


If name = ds.ToString Then
btn.Visible = True
Else
btn.Visible = False
End If

At this sentance btn.Visible = False, it give me this error:
Object reference not set to an instance of an object.

Can anyone help me in it? Thank very very much.
tiffany
 
Back
Top