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

  • Home
  • SEARCH
  • 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 525957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:43:34+00:00 2026-05-13T08:43:34+00:00

I have a DataRepeater with a GridView inside to display some tables from a

  • 0

I have a DataRepeater with a GridView inside to display some tables from a stored procedure.

Here is my repeater code:

<asp:Repeater ID="rptResults" runat="server" OnItemDataBound="rptResults_ItemDataBound">
    <ItemTemplate>
        <div style="width: 1100px; overflow: scroll;">
            <asp:GridView ID="gvResults" runat="server" BackColor="LightGoldenrodYellow" BorderColor="Tan"
                BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="None">
                <FooterStyle BackColor="Tan" Wrap="false" />
                <RowStyle Wrap="false" />
                <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center"
                    Wrap="false" />
                <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" Wrap="false" />
                <HeaderStyle BackColor="Tan" Font-Bold="True" Wrap="false" />
                <AlternatingRowStyle BackColor="PaleGoldenrod" Wrap="false" />
            </asp:GridView>
            <asp:Label runat="server" ID="lblNoRecords" Visible="false"></asp:Label>
        </div>
        <br />
    </ItemTemplate>
</asp:Repeater>

I have as my repeater binding:

    rptResults.DataSource = results.Tables;
    rptResults.DataBind();

I have the following for my GridView binding for each table:

protected void rptResults_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var o = e.Item.DataItem as DataTable;
                if (o.Rows.Count == 0)
                {
                    var lblNoRecords = (Label) e.Item.FindControl("lblNoRecords");
                    lblNoRecords.Text = "No Records";
                    lblNoRecords.Visible = true;
                }
                else
                {
                    var gv = (GridView)e.Item.FindControl("gvResults");
                    gv.DataSource = o;

                    gv.DataBind();    
                }

            }
        }

The data that comes back could change, since it is a stored procedure, and it will always return an n number of tables.

I would like to try to get my columns to auto size based on the data that is being returned. Right now it squishes most of the data, including date/time data.

I can’t seem to figure out how to do this.

Thoughts?

  • 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-13T08:43:34+00:00Added an answer on May 13, 2026 at 8:43 am

    Sorry if this is irrelevant, but I’m reading between the lines of your question and wondering if you are just trying to get certain columns (such as your date/time columns) not to wrap their contents, thus deferring the wrap to other columns (such as text columns)? The browser will generally try to layout the HTML table optimally. If you want certain columns not to wrap, you can use the CSS white-space: nowrap property.

    In a GridView using ItemTemplate, there is a Wrap=”False” property:

    <ItemTemplate>
        <asp:Label ID="Label1" runat="server" Text='<%# Bind("Data") %>'></asp:Label>
    </ItemTemplate>
    <ItemStyle Wrap="False" />
    

    If you want to use the auto-generated columns, you will have to handle the appropriate events on each generated GridView and then set the attributes in code-behind. Something like:

    protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        e.Row.Cells[2].Attributes.Add("style", "white-space: nowrap;");
    }
    

    Obviously you would first need to determine if the bound column data is of the type for which you want to forbid wrapping.

    The above is the worst-case scenario; you may get away with handling events that don’t fire as much (per-column perhaps), but I’m not sure if that will work in your situation.

    If you want the entire table not to wrap, you may be able to get away with just setting the CSS property on your page for all table.tr.td elements.

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

Sidebar

Ask A Question

Stats

  • Questions 309k
  • Answers 309k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The direct answer to your question is to alter the… May 13, 2026 at 10:00 pm
  • Editorial Team
    Editorial Team added an answer use CASE, or if the bit field is non-nullable you… May 13, 2026 at 10:00 pm
  • Editorial Team
    Editorial Team added an answer The problem is this code at the top of the… May 13, 2026 at 10:00 pm

Related Questions

The 'RenderPartial()' method in ASP.NET MVC offeres a very low level of functionality. It
I have a web-service that I will be deploying to dev, staging and production.
I have a .Net desktop application with a TreeView as one of the UI
I have a Queue<T> object that I have initialised to a capacity of 2,
I have a complete XML document in a string and would like a Document

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.