Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6169573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:52:46+00:00 2026-05-23T22:52:46+00:00

I have set up a GridView as set out below. You can see there

  • 0

I have set up a GridView as set out below. You can see there are four LinkButton’s per row. What I want to do is make certain LinkButtons available depending on which row they appear in.

<asp:GridView ID="FormsGrid" runat="server" Width="657px" Height="250px" DataKeyNames="FORM_NAME,FORM_ACCESS,STATUS,ID"
               AutoGenerateColumns="False" DataSourceID="SqlDataSource1" >
             <Columns>
                 <asp:BoundField DataField="DEADLINE_DATE" HeaderText="Date" DataFormatString="{0:d}"
                     SortExpression="DEADLINE_DATE" />
                 <asp:BoundField DataField="FORM_NAME" HeaderText="Event" 
                     SortExpression="FORM_NAME" >                     
                     <ItemStyle Width="240px" />
                 </asp:BoundField>
                 <asp:BoundField DataField="COMPULSORY" HeaderText="Compulsory?" 
                     SortExpression="COMPULSORY" />
                 <asp:BoundField DataField="FORM_NO" HeaderText="Form" 
                     SortExpression="FORM_NO" />     
                 <asp:TemplateField HeaderText="Access">
                     <ItemTemplate>
                         <asp:LinkButton ID="FormLinkBtn" runat="server"  
                             onclick="FormLinkBtn_Click">Form Link</asp:LinkButton>
                         <br />
                         <asp:LinkButton ID="NotReqBtn" runat="server"  
                             onclick="NotReqBtn_Click">Not Required</asp:LinkButton>
                         <br />
                         <asp:LinkButton ID="DnLoadBtn" runat="server"  
                             onclick="DnLoadBtn_Click">Download Pdf</asp:LinkButton>
                         <br />
                         <asp:LinkButton ID="UploadBtn" runat="server"  
                             onclick="UploadBtn_Click">Upload Pdf</asp:LinkButton>                             
                     </ItemTemplate>
                 </asp:TemplateField>
                 <asp:BoundField DataField="STATUS" HeaderText="Completed?" 
                     SortExpression="STATUS" />
                 <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" Visible="False" />
             </Columns>
         </asp:GridView>

When I try to make them not visible use the code below in FormsGrid_RowDataBound, it doesn’t work and a get a null value error.

if e.Row.Cells(4).Text = "1" then
   Dim FLbtn As LinkButton = FormsGrid.FindControl("FormLinkBtn")
   FLbtn.Visible = True
   Dim NRbtn As LinkButton = FormsGrid.FindControl("NotReqBtn")
   NRbtn.Visible = False
   Dim DLbtn As LinkButton = FormsGrid.FindControl("DnLoadBtn")
   DLbtn.Visible = False
   Dim ULbtn As LinkButton = FormsGrid.FindControl("UploadBtn")
   ULbtn.Visible = False
end if

Also when I click say the FormLinkBtn, how do I determine the value of the fields in that particualr row?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:52:48+00:00Added an answer on May 23, 2026 at 10:52 pm

    Suggestion #1:

    wrap your “if” statement in an “if” that checks for a row type:
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
    ……// your code here
    }
    You getting null value exception becuase first you hit the header row. There are few types of rows.
    You are only interested in DataRow in this case.

    On question part 2:

    if you go with just a link buttons and click events you will need to pass some data in CommandArgument or CommandName properties of the linkButton. You can use CommandField or ButtonField instead to avoid dealing with passing data identifying the row in CommandArgument or CommandName.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Gridview boundfield where i set ReadOnly to true because i don't
I have set of scripts for doing scripted installs. You can use the scripts
I have to do a sorting on headers of the gridview. i have set
We have set up a system where notifications get sent to a user with
I have set a canvas' background to an image of a company logo. I
I have set up transactional replication between two SQL Servers on different ends of
I have set up a version control system using TortoiseSVN at my home to
I have set up a Django application that uses images. I think I have
I have set the FlushMode property on an NHibernate session to FlushMode.Never, but when
I have set the itemRollOver and itemRollOut event listeners on a List component, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.