Skip to content

Add a button link to a single grid view row

Lynn Emery

Asked Mar 27, 2013, 12:33 AM EDT3 answers
Share
LinkedInX

Hi Does anyone know how to add a button link to a grid view to a single row in a grid view, rather than the entire column?

At the moment I have this:

Customer

Sales

Customer A

1000

Customer B

1005

Customer C

2500

However I want this:

Customer

Sales

Customer A

1000

Customer B

1005

Customer C

2500

I have created this first grid view using the following :

http://technico.qnownow.com/using-gridview-in-asp-net-c-part-2/

Thank you for your help.

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Suthish Nair
    0
    you can use e.Row.RowIndex == 0 on RowCreated or RowDataBound and create the link... or hide the link and show a lable control
    0
  • 0
    Thank you for your reply!
    Please could explain furher how I can hide the link.
    Again, Thank you for your help.
    0
  • Suthish Nair
    0
     Ok..
     
     Add two control, LinkButton and Label for column Customer. Both will bind with same value.

     Make sure any one of the control should be visible all the time.

     Now on GridView RowDataBound event check if e.Row.RowIndex == 0 (this means first row) then show LinkButton only and hide Label. Else for another row, hide LinkButton.
     
    0