bonjour,
dans un gridview quand il n'y a aucun enregistrement, le gridview n'affiche pas les entetes de colonnes
comment faire pour qu'ils soient quand meme present ?
Cdlt
Version imprimable
bonjour,
dans un gridview quand il n'y a aucun enregistrement, le gridview n'affiche pas les entetes de colonnes
comment faire pour qu'ils soient quand meme present ?
Cdlt
essaye de rajouter à ta gridview la propriété EMPTYDATATEXT = "il n'ya pas denregistrement "...
les colonnes devraient apparaitre
hey non :D
Euh... utilises un Datagrid à la place... !?! :roll:
envoi ton code stp
le code :
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127 <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_PreRenderComplete(object sender, EventArgs e) { try { this.GridView1.HeaderRow.TableSection = TableRowSection.TableHeader; } catch (Exception ee) { } } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> <style> .tablestyle{ font-family:arial; margin:10px 0pt 15px; font-size: 8pt; border-color: #CDCDCD; width:850px; color: #3D3D3D; padding-left:20px; } .tablestyle td, .tablestyle th{ border-color: #CDCDCD; } .alternatingrowstyle{ background-color:#F0F0F6; } .headerstyle { background-color:#F0F0F6; background-image: url(img/sort_none.gif); background-repeat: no-repeat; background-position: center left; } .headerstyle a{ text-decoration:none; color:black; display:block; padding-left:20px; } .rowstyle{ background-color: #FFF; } .rowstyle td, .alternatingrowstyle td { padding: 4px; } .sortascheaderstyle{ background-image: url(img/sort_asc.gif); background-color: #8dbdd8; background-repeat: no-repeat; background-position: center left; } .sortdescheaderstyle{ background-image: url(img/sort_desc.gif); background-color: #8dbdd8; background-repeat: no-repeat; background-position: center left; } </style> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView CssClass = "tablestyle" ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="RDV_numero" DataSourceID="AccessDataSource1" EmptyDataText="There are no data records to display." > <Columns> <asp:BoundField DataField="RDV_numero" HeaderText="RDV_numero" InsertVisible="False" ReadOnly="True" SortExpression="RDV_numero" /> <asp:BoundField DataField="RDV_type_RDV" HeaderText="RDV_type_RDV" SortExpression="RDV_type_RDV" /> <asp:BoundField DataField="RDV_code_dossier" HeaderText="RDV_code_dossier" SortExpression="RDV_code_dossier" /> <asp:BoundField DataField="RDV_date" HeaderText="RDV_date" SortExpression="RDV_date" /> <asp:BoundField DataField="RDV_confirmation" HeaderText="RDV_confirmation" SortExpression="RDV_confirmation" /> <asp:BoundField DataField="RDV_suppr_commentaire" HeaderText="RDV_suppr_commentaire" SortExpression="RDV_suppr_commentaire" /> <asp:BoundField DataField="RDV_nb_passage" HeaderText="RDV_nb_passage" SortExpression="RDV_nb_passage" /> <asp:BoundField DataField="RDV_RDV_telephonique" HeaderText="RDV_RDV_telephonique" SortExpression="RDV_RDV_telephonique" /> </Columns> <HeaderStyle CssClass="headerstyle" /> </asp:GridView> <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="C:\Documents and Settings\dtenketkian\RIO DVLPT\BDD_RIO.mdb" SelectCommand="SELECT [RDV_numero], [RDV_type_RDV], [RDV_code_dossier], [RDV_date], [RDV_confirmation], [RDV_suppr_commentaire], [RDV_nb_passage], [RDV_RDV_telephonique] FROM [RDV] where [RDV_type_RDV] ='1' "> </asp:AccessDataSource> <br /> <br /> </div> </form> </body> </html>
essaye ça !
if (GridView1.Rows.Count == 0)
{
GridView1.Visible = true;
}
en fait quand il n'y a pas d'enregistrement à mon gridview je veux qu'il garde quand meme les en-têtes(header) de mon gridview
essaye ca alors !
if (GridView1.Rows.Count == 0)
{
GridView1.HeaderRow.Cells = true;
}
je crois que GridView1.HeaderRow.Cells est en lecture seule
il ya un moyen de le faire, atend je cherche
je vais essayer de creuser comment faire pour ajouter des en-têtes par le code behind
fais ça :
Code:
1
2
3
4 if (GridView1.Rows.Count == 0) { GridView1.ShowHeader = true; }