Solved

ASP.net : how to set column width in datagrid

Posted on 2011-02-11
5
724 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 250 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 250 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

734 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