简体   繁体   中英

Gridview using html in ASP.NET

I have a doubt in gridview design can anyone help me. I have created a gridview, but when im giving any text to that grid cell my grid design is changing. My question is how to give a fixed height to the gridview even if we are entering text into one cell or no: of cells. And Here is my code. Thank You in Advance.

     <asp:GridView ID="GrvSchoolName1" runat="server"  AllowPaging="True" PageSize="4"       Height="30px" BackColor="White" 
                    BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px"    CellPadding="3" 
                    GridLines="Vertical" CssClass="grvclass"
                    AutoGenerateColumns="False"                           
                    ForeColor="Black" onpageindexchanging="GrvSchoolName1_PageIndexChanging">
            <PagerSettings Mode="NumericFirstLast" PageButtonCount="4"  FirstPageText="First" LastPageText="Last"/> 
              <AlternatingRowStyle BackColor="#CCCCCC" />

            <Columns>
            <asp:TemplateField HeaderText="Emergency Alert" HeaderStyle-Height="30px">
                <ItemTemplate>
                 <div style="overflow:auto; height:60px;">
                    <asp:Label ID="Label1" runat="server" Text='<% #Eval("AlertMessage") %>' ></asp:Label>
                </div>
                </ItemTemplate>
            </asp:TemplateField>
           </Columns>
                <FooterStyle BackColor="#CCCCCC" />
                <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
                <SortedAscendingCellStyle BackColor="#F1F1F1" />
                <SortedAscendingHeaderStyle BackColor="#808080" />
                <SortedDescendingCellStyle BackColor="#CAC9C9" />
                <SortedDescendingHeaderStyle BackColor="#383838" />
          </asp:GridView>
          </div>

Give a css class to your itemstyle template. Same works for the header :)

.NET

<ItemStyle CssClass="items"> </ItemStyle>


<ItemTemplate>
your stuff
</ItemTemplate>

CSS.

.items{width:200px;}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM