Using a table in ASP.NET

I have a table that (in a user control) that holds 2 columns and a bunch of rows. There is one row I need to populate when theres a value(not a problem) but when there is no value I want to collapse the <tr> and move on. There are controls in the tr like a label on one column and a text box holds the value and there is also a placeholder control. All I want to do is collapse(?) the row when there is no value. I see alot of javascript out there that does this but Im new to all this so Im not sure how to call the script or where to put the script(in the control or on the form that holds the user control?)
Can someone please help with this. I am trying to figure it out in the source code but I havent been able to do it just yet.
Im using ASP.NET 2012 .NET 4.0(VB source code)

Thanks
JK
jknj72Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Randy DownsOWNERCommented:
Maybe you can adapt this .

   Private Sub TestGridView_DataBindingComplete(ByVal sender As Object, _
    ByVal e As DataGridViewBindingCompleteEventArgs) _
    Handles DataGridView1.DataBindingComplete
 
        For Each Row As DataGridViewRow In CType(sender, DataGridView).Rows
            Dim Visible As Boolean = True
 
            'Do this to inspect all cells in the row
            For i As Integer = 0 To Row.Cells.Count - 1
                If Row.Cells(i).Value Is Nothing Then
                    Visible = False
                    Exit For
                End If
            Next
 
            'Or you can check specific columns for their values
            If Row.Cells(0).Value Is Nothing OrElse _
            (IsNumeric(Row.Cells(0).Value) AndAlso CInt(Row.Cells(0).Value) < 0) Then
                Visible = False
            End If
 
            Row.Visible = Visible
        Next
    End Sub

Open in new window

Ess KayEntrapenuerCommented:
i would check in asp if there is data, if true,  then add row,  else dont add row.


or are you trying to do a fancy css where the thung collapses like an accordion
Ess KayEntrapenuerCommented:
basically if you choose option 1, move the TR tag inside your asp code




so instead of

<tr><td>  <asp: value stuff> </td></tr>

you would do something like

 <asp..  if value exists  "<tr><td>" & valuestuff& "</td></tr>"   >


~~sorry for pseudocode,  im on cellphone
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

jknj72Author Commented:
Randy, Im using a table not a gridview. Although, I though of converting the table into a grid but I dont have the time to do so. I simply want to keep the designated row at the original height and when populating the table with data, if there is no data for this row I would like to collapse it. I have another question as well. If there is a value I add a link to the <td> and I want to open up a new window with that is already in place. I just dont have the syntax down yet. Here is what I had given to me...
--first argument is an id and the second is supposed to be the screen resolution but I will figure that out. I just need to know if that is the right syntax to open up a new page? I will post a new question for this one...
"<a id="PcovIndivControl1_PcovAllNamesLink" class="PcovIndivLabelsBold"  onclick="OpenNewWindow('20140501060253390384276WBGZW2551       263','')" href="#">Additional Names on File. Click Here to view...</a>"
Randy DownsOWNERCommented:
Maybe you can adapt this. They are hiding based on a value you will want to hide based on null, maybe.

The complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E2767.

The following example demonstrates how to hide particular rows and columns by handling the CustomFieldValueCells Event.

In this example, the event handler iterates through all row headers and removes rows that correspond to the "Employee B" field value, and that are not Total Rows.
jknj72Author Commented:
Randy, I appreciate your help but once again, I am not using a grid....I am using an html table and I dont have these properties with the table ...
Ess KayEntrapenuerCommented:
to open a new window use the tag  _default
Ess KayEntrapenuerCommented:
sorry i meant blank not default


<a href="http://www.abc.com" target="_blank">Visit abc.com!</a>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ess KayEntrapenuerCommented:
if you don't want row to show,  and using table,  use code i have above
Ess KayEntrapenuerCommented:
try this code on for size,  its how to create html table in asp dynamically http://www.dotnetcurry.com/ShowArticle.aspx?ID=135
jknj72Author Commented:
thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.