We help IT Professionals succeed at work.
Get Started

How to check for a row and remove it based on a commandfield click

dba123
dba123 asked
on
370 Views
Last Modified: 2011-04-14
Ok, I am not sure how I can undo my creation of rows based on the user clicking my image button.

So far, what works, is when the user clicks on the commandfield control below in my GridView, the images changes to a minus (hence collapses the gridview row to reveal it's detailed row which is newly created by my CreateRow method below)

<asp:commandfield  buttontype="Image" selectimageurl="/images/plus.gif" showselectbutton="True" />

When the user clicks the control again, the image goes back to plus.  I am not sure how to:

a) capture if the user has expanded or collapsed since there is no ID attribute on a commandfield that I can grab onto to maybe do something like a check on the image to determine that
b) How to check if the CreateRow created a row before and undo it if it has...hence collapse

I am new to commandfield so bare with me.  Here's the function that actually creates the row, underneath the current row that the user has selected (selected mean by clicking on the commandfield image which changes form a plus to minus icon or vice versa when clicked)

    Private Sub CreateRow(ByVal table As Table, ByVal index As Integer)
        Dim row As GridViewRow = New GridViewRow(-1, -1, DataControlRowType.DataRow, DataControlRowState.Normal)
        Dim selectedrow As GridViewRow = SearchResults.Rows(index)
        Dim StfID As Integer = SearchResults.DataKeys(index).Value
        row.Cells.Add(CreateColumn(StfID, index))
        table.Rows.AddAt(index + 2, row)
    End Sub

so how do I do the opposite?  How can I check to even see if the CreateRow is even there.  It's a bit tricky and not sure how to attack this
Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE