We help IT Professionals succeed at work.
Get Started
Private
Troubleshooting Question

Can't force ASP.Net GridView column to fixed width

zipnotic
zipnotic asked
on
86 Views
Last Modified: 2020-09-28
I'm new at asp.net and I'm trying to display data in a Grid View control.  The last column contains a series of email addresses separated by commas so it can get long.  I'd like to keep it on 1 line so it doesn't wrap but keep the column to a percentage or fixed pixels.  No matter what I do it always expands to show all of the emails and it stretches off the right side of the screen.  Been looking into all sorts of solutions including CSS which hasn't worked.

Ideally what I'm after is to display the first 25 characters or so and then a ... to signify there are more emails.  Hovering over the field gives a pop up of the whole field or something but maybe I'm too used to WinForms.
 
Any guidance would be greatly appreciated.

Here is my aspx:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Going Nutz!!!</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>


            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4">
                <Columns>
                        <asp:BoundField DataField="RecordID" HeaderText ="ID" SortExpression="RecordID" />
                        <asp:Hyperlinkfield HeaderText ="CaseNo" sortexpression="CaseNo" datatextfield ="CaseNo" NavigateUrl="CLink" />
                        <asp:BoundField DataField="Status" HeaderText ="Status" sortexpression="Status" >
                        <ItemStyle Wrap="False" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Type" HeaderText ="Type" sortexpression="Type">
                        <ItemStyle Wrap="False" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Staff" HeaderText ="Staff" sortexpression="Staff" >
                        <HeaderStyle HorizontalAlign="Center" />
                        <ItemStyle Wrap="False" />
                        </asp:BoundField>
                        <asp:BoundField DataField="WClass" HeaderText ="WClass" sortexpression="WClass" >
                        <ItemStyle Wrap="False" />
                        </asp:BoundField>

                        <asp:BoundField DataField="First" HeaderText ="First" sortexpression="First" />
                        <asp:BoundField DataField="Last" HeaderText ="Last" sortexpression="Last"/>
                        <asp:BoundField DataField="DOB" HeaderText ="DOB" sortexpression="DOB" >
                        <ItemStyle Wrap="False" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Emails" HeaderText ="Emails" ItemStyle-Width="400px" FooterStyle-Width="400px" sortexpression="Emails" >
                        <FooterStyle Width="400px"></FooterStyle>
                        <HeaderStyle Width="200px" Wrap="False" />
                        <ItemStyle Width="400px"></ItemStyle>
                        </asp:BoundField>
                </Columns>
                <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
                <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
                <PagerStyle ForeColor="#003399" HorizontalAlign="Left" BackColor="#99CCCC" />
                <RowStyle BackColor="White" ForeColor="#003399" />
                <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
                <SortedAscendingCellStyle BackColor="#EDF6F6" />
                <SortedAscendingHeaderStyle BackColor="#0D4AC4" />
                <SortedDescendingCellStyle BackColor="#D6DFDF" />
                <SortedDescendingHeaderStyle BackColor="#002876" />
            </asp:GridView>


        </div>
    </form>
</body>
</html>

Comment
Watch Question
Sr. System Analyst
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 31 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

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
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