Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 13th, 2006, 02:16 PM
Authorized User
 
Join Date: Jan 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Datagrid column alignment

I am using a .NET datagrid on a page. The grid has some columns that are not visible, and another column that checks on a condition in the database and is only displays the template item if the condition is met. The column folowing this is a button column.

My problem is that when the program runs and fills the datagrid the button column displays its text in different places.

It displays like below, with the '*' representing the image that appears if the condition is met.

System Reports
• * Testin Link
• Premissions
• Perm Super Corp Perm
• * Yahoo


I have set the horizontal alignment to left for all of the columns, and I have set the width of the image to the images actual width.

I also have other datagrids on the page that are configured the exact same way as each other, yet the columns on one datagrid do not always align with the columns on the other. I cannot figure out what the problem is.

Below is part of the HTML creating two of the datagrids.


                    <TD vAlign="top" noWrap align="left" width="50%" colSpan="1" rowSpan="1"><asp:label id="lblCat1" runat="server" Width="408px" Font-Size="11.5pt" ForeColor="Navy" BackColor="#CCCCCC"
                            Font-Bold="True" Font-Names="Georgia"></asp:label><asp:datagrid id="dgCatID1" runat="server" Width="408px" GridLines="Horizontal" ShowHeader="False"
                            AutoGenerateColumns="False" BorderColor="White" BorderWidth="2px" Font-Size="9pt" HorizontalAlign="Left" Font-Names="Arial">
                            <AlternatingItemStyle Wrap="False" HorizontalAlign="Left"></AlternatingItemStyle>
                            <ItemStyle Wrap="False" HorizontalAlign="Left"></ItemStyle>
                            <HeaderStyle BackColor="LightSlateGray"></HeaderStyle>
                            <Columns>
                                <asp:BoundColumn Visible="False" DataField="category_id"></asp:BoundColumn>
                                <asp:BoundColumn Visible="False" DataField="category"></asp:BoundColumn>
                                <asp:BoundColumn Visible="False" DataField="link_name"></asp:BoundColumn>
                                <asp:TemplateColumn>
                                    <ItemTemplate>
                                        â€¢
                                    </ItemTemplate>
                                </asp:TemplateColumn>
                                <asp:TemplateColumn>
                                    <ItemStyle Wrap="False"></ItemStyle>
                                    <ItemTemplate>
                                        <asp:Image id="Image1" runat="server" ImageUrl="NEW.gif"></asp:Image>
                                    </ItemTemplate>
                                </asp:TemplateColumn>
                                <asp:ButtonColumn DataTextField="link_name" CommandName="goURL">
                                    <ItemStyle HorizontalAlign="Left"></ItemStyle>
                                </asp:ButtonColumn>
                                <asp:BoundColumn Visible="False" DataField="link_URL"></asp:BoundColumn>
                            </Columns>
                        </asp:datagrid></TD>
                    <TD vAlign="top" noWrap align="left" width="50%" colSpan="1" rowSpan="1"><asp:label id="lblCat2" runat="server" Width="408px" Font-Size="11.5pt" ForeColor="Navy" BackColor="#CCCCCC"
                            Font-Bold="True" Font-Names="Georgia"></asp:label><asp:datagrid id="dgCatID2" runat="server" Width="408px" GridLines="Horizontal" ShowHeader="False"
                            AutoGenerateColumns="False" BorderWidth="2px" BorderColor="White" Font-Size="9pt" Font-Names="Arial" HorizontalAlign="Left">
                            <AlternatingItemStyle Wrap="False" HorizontalAlign="Left"></AlternatingItemStyle>
                            <ItemStyle Wrap="False" HorizontalAlign="Left"></ItemStyle>
                            <HeaderStyle BackColor="LightSlateGray"></HeaderStyle>
                            <Columns>
                                <asp:BoundColumn Visible="False" DataField="category_id"></asp:BoundColumn>
                                <asp:BoundColumn Visible="False" DataField="category"></asp:BoundColumn>
                                <asp:BoundColumn Visible="False" DataField="link_name"></asp:BoundColumn>
                                <asp:TemplateColumn>
                                    <ItemStyle Wrap="False"></ItemStyle>
                                    <ItemTemplate>
                                        â€¢
                                    </ItemTemplate>
                                </asp:TemplateColumn>
                                <asp:TemplateColumn>
                                    <ItemStyle Wrap="False" HorizontalAlign="Left"></ItemStyle>
                                    <ItemTemplate>
                                        <asp:Image id="Image2" runat="server" ImageUrl="NEW.gif"></asp:Image>
                                    </ItemTemplate>
                                </asp:TemplateColumn>
                                <asp:ButtonColumn DataTextField="link_name" CommandName="goURL">
                                    <ItemStyle Wrap="False" HorizontalAlign="Left"></ItemStyle>
                                </asp:ButtonColumn>
                                <asp:BoundColumn Visible="False" DataField="link_URL">
                                    <ItemStyle Wrap="False"></ItemStyle>
                                </asp:BoundColumn>
                            </Columns>
                        </asp:datagrid></TD>
                </TR>







Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting column name/header of a datagrid elygp ASP.NET 1.0 and 1.1 Professional 2 June 6th, 2007 01:07 PM
Header Alignment in System.Windows.Foms.DataGrid pushkar ADO.NET 0 March 30th, 2005 02:05 AM
Find column in datagrid Lesviper VB How-To 0 March 9th, 2005 07:54 AM
Text alignment in datagrid pdsluk ASP.NET 1.0 and 1.1 Basics 0 October 21st, 2003 05:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.