Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ASP.net : how to set column width in datagrid

Posted on 2011-02-11
5
Medium Priority
?
728 Views
Last Modified: 2012-05-11
Hi,
  I'm very new to ASP.net. I have a datagrid that allows viewing and update of records and i would like to set the column width accordingly.The records should be displayed on a single line with no wrapping.  I've tried ItemStyle-Width ..etc with no luck. Please help me with the following code snippet. Thanks in advance.

 <asp:datagrid id="DataGrid1" runat="server" Width="600px" Font-Names="Arial" AutoGenerateColumns="False" CellSpacing="1" GridLines="None" CellPadding="3" BackColor="White" OnPageIndexChanged="DataGrid_Page" PageSize="20" OnCancelCommand="DataGrid_Cancel" OnUpdateCommand="DataGrid_Update" OnEditCommand="DataGrid_Edit" Font-Size="XX-Small" ForeColor="Black">
                <FooterStyle wrap="False" backcolor="#C6C3C6"></FooterStyle>
                <HeaderStyle font-bold="True" wrap="False" horizontalalign="Center" forecolor="White" backcolor="#0000C0"></HeaderStyle>
                <PagerStyle font-size="XX-Small" horizontalalign="Right" backcolor="#C6C3C6" wrap="False" mode="NumericPages"></PagerStyle>
                <SelectedItemStyle wrap="False"></SelectedItemStyle>
                <EditItemStyle wrap="False"></EditItemStyle>
                <AlternatingItemStyle wrap="False"></AlternatingItemStyle>
                <ItemStyle wrap="False" backcolor="#DEDFDE"></ItemStyle>
                <Columns>
                    <asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel" EditText="Edit">
                        <ItemStyle font-size="XX-Small" width="10%"></ItemStyle>
                    </asp:EditCommandColumn>
                    <asp:TemplateColumn HeaderText="SO #">
                        <ItemStyle horizontalalign="Center"></ItemStyle>
                        <ItemTemplate>
                            <%# Container.DataItem("STDOCO") %>
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:TextBox id="SOTxt" runat="server" horizontalalign="Center" Columns="4" />
                        </FooterTemplate>
                        <EditItemTemplate>
                            <asp:TextBox id="SO" runat="server" Text='<%# Container.DataItem("STDOCO") %>' horizontalalign="Center" Columns="4" readonly="true" ForeColor="Gray" />
                        </EditItemTemplate>
                    </asp:TemplateColumn>
            </Columns>
            </asp:datagrid>

0
Comment
Question by:DB-IT
5 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 1000 total points
ID: 34868970
Try any of these entries to prevent word wrap. By default word wrap is turned on.

<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 109px; POSITION: absolute; TOP: 94px" runat="server">
    <SelectedItemStyle Wrap="False"></SelectedItemStyle>
    <EditItemStyle Wrap="False"></EditItemStyle>
    <AlternatingItemStyle Wrap="False"></AlternatingItemStyle>
    <ItemStyle Wrap="False"></ItemStyle>
    <HeaderStyle Wrap="False"></HeaderStyle>
    <FooterStyle Wrap="False"></FooterStyle>
    <PagerStyle Wrap="False"></PagerStyle>
</asp:DataGrid
0
 
LVL 9

Expert Comment

by:s_chilkury
ID: 34868983
0
 
LVL 3

Assisted Solution

by:amittripathi8
amittripathi8 earned 1000 total points
ID: 34869828
it's better to ste all the things in % beacuse it will work according to resolution you have.
0
 
LVL 19

Expert Comment

by:Amandeep Singh Bhullar
ID: 35906815
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month12 days, 16 hours left to enroll

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question