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 361275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:52:51+00:00 2026-05-12T12:52:51+00:00

I have to display some tabular data where there is a maximum of 3

  • 0

I have to display some tabular data where there is a maximum of 3 columns to be displayed, but sometimes, only 1 or 2 are required. Thus far, I have:

<asp:FormView ID="myFormView" runat="server" DataSourceID="myXmlDataSource">
    <ItemTemplate>
        <table cellspacing="0" cellpadding="0" class="myTableStyle">
            <colgroup>
                <col class="myCol1Style" />
                <col class="myCol2Style" />
                <col class="myCol3Style" />
            </colgroup>
            <thead>
                <tr>
                    <th class="myCol1HeaderStyle">Column 1</th>
                    <th class="myCol2HeaderStyle">Column 2</th>
                    <th class="myCol3HeaderStyle">Column 3</th>
                </tr>
            </thead>
            <tr>
                <td>
                    <p>Column 1 data goes here</p>
                </td>
                <td>
                    <p>Column 2 data goes here</p>
                </td>
                <td>
                    <p>Column 3 data goes here</p>
                </td>
            </tr>
        </table>
    </ItemTemplate>
</asp:FormView>
<asp:XmlDataSource ID="myXmlDataSource" runat="server" />

Column 1 will always be displyed, but in some cases, I’ll need to hide column 2 and/or 3.

What would be the best way to handle this?

  • 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-12T12:52:51+00:00Added an answer on May 12, 2026 at 12:52 pm

    I would suggest using a GridView control with “AutoGenerateColumns” set to true, instead of a FormView control. Then bind it to your datasource, and it will always show the same number of columns that your datasource has.

    If you need to hide columns on the basis of user events rather than the data in them, then GridView ultimately will give you a lot more control over rows/columns.

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

Sidebar

Related Questions

i have two foreach loop to display some data, but i want to use
Say you have some tabular data you want to display, as well as allow
I have a JTable that I want to use to display some data (a
I have a custom Dialog that contains only a TextView to display some text
In a frame I have two columns. In the first column I display some
I have some data that I have to display as a table. I think
I have a large image. But i have to display just some portion of
We have a web part on which we display some data in a grid.
I'm using a JEditorPane to display some HTML data, however any images that have
I have written a script to graphically display some row-oriented data, with bars, labels

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.