Bonjour,
Le problème est le suivant : j'ai une gridview alimentée par un sqldatasource, ces deux éléments sont inclus dans un content d'une page qui elle-même est liée à une master page. Lorsque je clique sur la page 2, par exemple, plus rien n'apparaît. Pourtant lors du débugging, aux évènements PageIndexChanging et PageIndexChanged, ma gridview est toujours liée au datasource de départ.
voici les parties de code :
MasterPage (déclaration des contents) :
Page acceuil
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 <asp:contentplaceholder id="MenuContent" runat="server"> </asp:contentplaceholder> <asp:ContentPlaceHolder ID="OutPutContent" runat="server"> </asp:ContentPlaceHolder>
j'ai l'impression qu'il vide mon gridview de ses données après les événèments PageIndexChanging et PageIndexChanged car la page m affiche No Data Found , propriété de EmptyDataText
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 <asp:Content ID="AccueilOutput" ContentPlaceHolderID="OutputContent" Runat="Server"> <asp:GridView ID="ListTableDeviations" runat="server" EmptyDataText="No Data Found" AutoGenerateColumns="False" style="font-size: 8pt; color: white; font-family: Arial" AllowPaging="True" AllowSorting="True" ForeColor="Black" PageSize="20" AutoGenerateSelectButton="True" OnPageIndexChanged="ListTableDeviations_PageIndexChanged" OnPageIndexChanging="ListTableDeviations_PageIndexChanging" OnSorting="ListTableDeviations_Sorting"> <Columns> ... </Columns> <RowStyle ForeColor="Black" /> <HeaderStyle BackColor="Transparent" BorderColor="Black" ForeColor="Maroon" /> <EditRowStyle ForeColor="Black" /> </asp:GridView>
Code c#
merci pour votre aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 private string GlobalSQL; protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false) { ListTableApprobations.Visible = false; ListTableDeviations.Visible = false; } else { SqlDataSource1.SelectCommand = "SELECT * FROM QSWB.T_6420_DEVIATIONS_EVE "; SqlDataSource1.DataBind(); ListTableDeviations.DataSourceID = SqlDataSource1.ID; ListTableDeviations.DataBind(); ListTableDeviations.Visible = true; } } protected void ListTableDeviations_PageIndexChanged(object sender, EventArgs e) { Debug.WriteLine("CHANGED : " + ListTableDeviations.PageIndex); Debug.WriteLine("VISIBLE : " + ListTableDeviations.Visible); Debug.WriteLine("SOURCE DU DATAVIEW : " + ListTableDeviations.DataSourceID); } protected void ListTableDeviations_PageIndexChanging(object sender, GridViewPageEventArgs e) { Debug.WriteLine("CHANGING : " + ListTableDeviations.PageIndex); Debug.WriteLine("PAGE INDEX : " + e.NewPageIndex); GlobalSQL = "SELECT * FROM QSWB.T_6420_DEVIATIONS_EVE "; SqlDataSource1.SelectCommand = GlobalSQL; SqlDataSource1.DataBind(); ListTableDeviations.DataSourceID = SqlDataSource1.ID; ListTableDeviations.DataBind(); Debug.WriteLine("SQL source : " + GlobalSQL); Debug.WriteLine("Sql data source : " + ListTableDeviations.DataSourceID); ListTableDeviations.PageIndex = e.NewPageIndex; ListTableDeviations.Visible = true; }
Partager