Pergunta

I have a DataGrid control with BoundColumns. The rows are dynamically added. How do I keep the row height fixed as for now the row height is generated according to the contents of the column?

Currently the DataGrid is overflowing. I tried to limit the height of the rows but could not find a solution. I need the rows to have a fixed height regardless of the length of the content.

<asp:DataGrid ID="DataGrid1" runat="server"
              AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" 
              BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" 
              CellPadding="3" Font-Size="XX-Small" 
              OnItemCommand="DataGrid1_ItemCommand" Width="720px"
              OnPageIndexChanged="DataGrid1_PageIndexChanged" TabIndex="-1" >

            <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />

            <SelectedItemStyle BackColor="#738A9C" ForeColor="#F7F7F7" />

            <AlternatingItemStyle BackColor="#F7F7F7" />

            <ItemStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" Width="712px"/>

            <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" Font-Size="XX-Small" ForeColor="#F7F7F7" Width="712px"/>

            <Columns>
                <asp:ButtonColumn CommandName="show" DataTextField="TASK_ID" HeaderText="Ticket No."><ItemStyle Width="60px"/></asp:ButtonColumn>                    
                <asp:BoundColumn DataField="AGENT_ID" HeaderText="Agent"><ItemStyle Width="120px"/></asp:BoundColumn>                   
                <asp:BoundColumn DataField="TASK_DESCRIPTION" HeaderText="Task Description"><ItemStyle Width="300px" CssClass="colStyle"/></asp:BoundColumn>
                <asp:BoundColumn DataField="TASK_ASSIGNED_DATE" HeaderText="Job Date"><ItemStyle Width="60px"/></asp:BoundColumn>
                <asp:BoundColumn DataField="TASK_EXPECTED_DATE" HeaderText="Expected Date"><ItemStyle Width="80px"/></asp:BoundColumn>
                <asp:BoundColumn DataField="TASK_COMPLETED_DATE" HeaderText="Completed Date"><ItemStyle Width="100px"/></asp:BoundColumn>                    
                <asp:BoundColumn DataField="TASK_STATUS" HeaderText="Status"><ItemStyle Width="40px"/></asp:BoundColumn>                    
                <asp:BoundColumn DataField="TASK_ID" Visible="false"></asp:BoundColumn>
            </Columns>

            <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" Mode="NumericPages" /></asp:DataGrid>
Foi útil?

Solução

This has been solved by adding a Wrap property in ItemStyle and setting the value to False.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top