comment puis-je faire ma gridview pour s'adapter à 100% à la page
Comment puis-je faire ma gridview pour s'intégrer parfaitement à l'intérieur de l'écran.
J'ai ajouté cette propriété width="100%" je me. Cependant mon gridview toujours s'étend bien au-delà de l'en-tête de la largeur que j'ai comme 100%.
Voici mon code source de mon gridview pour la première tentative.
<asp:GridView ID="GWCase" runat="server" Top="0%" Width="100%" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" ForeColor="Black" Height="199px" AutoGenerateSelectButton="True" OnSelectedIndexChanged="GWCase_SelectedIndexChanged">
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<RowStyle BackColor="White" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#808080" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
</asp:GridView>
J'ai essayé d'utiliser la méthode css comme ceci
<ul id="assigngw">
<asp:GridView ID="GWCase" runat="server" Top="0%" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" ForeColor="Black" Height="199px" AutoGenerateSelectButton="True" OnSelectedIndexChanged="GWCase_SelectedIndexChanged">
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<RowStyle BackColor="White" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#808080" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
</asp:GridView>
</ul>
Code Css :
#assigngw {
width:100%;
}
Malheureusement les deux ne fonctionne pas.
Voici mon code source complet.
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<link rel="stylesheet" href="css/style.css" type="text/css" />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<ul id="assigngw">
<asp:GridView ID="GWCase" runat="server" width="300px" Top="0%" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" ForeColor="Black" Height="199px" AutoGenerateSelectButton="True" OnSelectedIndexChanged="GWCase_SelectedIndexChanged">
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<RowStyle BackColor="White" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#808080" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
</asp:GridView>
</ul>
<br />
Case ID :
<asp:Label ID="lblCID" runat="server"></asp:Label>
is situation near
<asp:DropDownList ID="lblocation" runat="server" OnSelectedIndexChanged="lblocation_SelectedIndexChanged" AutoPostBack="True" DataTextField="location" DataValueField="location">
<asp:ListItem>Select Location</asp:ListItem>
<asp:ListItem>Bukit Batok NPC</asp:ListItem>
<asp:ListItem>Bukit Panjang NPC</asp:ListItem>
<asp:ListItem>Choa Chu Kang NPC</asp:ListItem>
<asp:ListItem>Jurong West NPC</asp:ListItem>
<asp:ListItem>Nanyang NPC</asp:ListItem>
<asp:ListItem>Woodlands East NPC</asp:ListItem>
<asp:ListItem>Woodlands West NPC</asp:ListItem>
<asp:ListItem>Ang Mo Kio North NPC</asp:ListItem>
<asp:ListItem>Ang Mo Kio South NPC</asp:ListItem>
<asp:ListItem>Punggol NPC</asp:ListItem>
<asp:ListItem>Hougang NPC</asp:ListItem>
<asp:ListItem>Sembawang NPC</asp:ListItem>
<asp:ListItem>Serangoon NPC</asp:ListItem>
<asp:ListItem>Sengkang NPC</asp:ListItem>
<asp:ListItem>Yishun North NPC</asp:ListItem>
<asp:ListItem>Yishun South NPC</asp:ListItem>
<asp:ListItem>Bedok North NPC</asp:ListItem>
<asp:ListItem>Bedok South NPC</asp:ListItem>
<asp:ListItem>Changi NPC</asp:ListItem>
<asp:ListItem>Geylang NPC</asp:ListItem>
<asp:ListItem>Marine Parade NPC</asp:ListItem>
<asp:ListItem>Pasir Ris NPC</asp:ListItem>
<asp:ListItem>Tampines NPC</asp:ListItem>
<asp:ListItem>Bukit Merah West NPC</asp:ListItem>
<asp:ListItem>Clementi NPC</asp:ListItem>
<asp:ListItem>Queenstown NPC</asp:ListItem>
<asp:ListItem>Jurong East NPC</asp:ListItem>
<asp:ListItem>Bishan NPC</asp:ListItem>
<asp:ListItem>Bukit Timah NPC</asp:ListItem>
<asp:ListItem>Kampung Java NPC</asp:ListItem>
<asp:ListItem>Orchard NPC</asp:ListItem>
<asp:ListItem>Toa Payoh NPC</asp:ListItem>
<asp:ListItem>Bukit Merah East NPC</asp:ListItem>
<asp:ListItem>Rochor NPC</asp:ListItem>
<asp:ListItem>Marina Bay NPC</asp:ListItem>
</asp:DropDownList>
<br />
<br />
The following case will be assigned to this selected officer
<asp:DropDownList ID="DDLpolice" runat="server" DataTextField="dropdownpolice" DataValueField="dropdownpolice" OnSelectedIndexChanged ="DDLpolice_SelectedIndexChanged1" style="height: 22px"
AppendDataBoundItems="true" AutoPostBack="True">
<asp:ListItem Value="-1">Select Officer</asp:ListItem>
</asp:DropDownList>
- Les gars, cette question n'est pas une mauvaise. Il est légitime et bien formé. Pourquoi downvote?
- En fait, je me demandais aussi la même chose aussi. 😛
Vous devez vous connecter pour publier un commentaire.
Le problème est avec votre contenu de l'examen et de la poubelle de texte.
Ajouter:
Cela permettra à chaque cellule de pause sur les longues phrases qui ne correspondent pas et ne l'arrêtera l'augmentation de la taille de l'affichage de la grille.
MODIFIER
Essayer cette
La clé ici est
table-layout: fixed;
puisqu'elle force les cellules à s'adapter à la table au lieu de la table de l'expansion pour s'adapter à l'cellules.Mis à jour jsFiddle
Vous pouvez également mettre votre gridview dans un div, comme cette
<div style="width:100%;overflow:scroll;">
<i>your gridview here</i>
</div>
Avec cela, le contrôle gridview ne s'étend pas au-delà de la largeur de la page. Mais l'utilisateur fait défiler verticalement sur la page pour afficher tous les gridview contenu.
C'est le long texte sans espace dans la ligne qui est en poussant la grille à la sortie. Vous devez ajouter l'attribut style
word-wrap:break-word;
à la cellule si vous voulez le texte afin de le briser.