简体   繁体   中英

How can I set visibility of button in dataitemTemplate to true/false on vb.net page load?

I have enquiry on how to set visibility of button in dataitemplate to true/false on vb.net page load? I have tried to implement line of code but error Object reference not set to an instance of an object, please guide me on this.

My code is illustrated as below:

ASP.net

    <dx:GridViewDataTextColumn VisibleIndex="20" Width="130px">                                   
     <DataItemTemplate> 
        <dx:ASPxButton ID="acptbtn" runat="server" Visible="False" Text="Accept" OnClick="acptbtn_Click"></dx:ASPxButton>     
     </DataItemTemplate>  
   </dx:GridViewDataTextColumn>

VB.net

Private Sub Pg_Load(sender As Object, e As EventArgs) Handles Me.Load   
 If checkId(Session("Id")) Then

            Dim But1 As Button = XGrid.FindControl("acptbtn")
            But1.Visible = True    
 End If   
End Sub
Protected Sub OnRowDataBound(sender As Object, e As GridViewRowEventArgs)
    For Each gvItem As GridDataItem In XGrid.Items
          Dim But1 As Button = XGrid.FindControl("acptbtn")
          But1.Visible = True  
    Next
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM