Bonjour à tous,
Débutant dans le développement web par visual studio, je me retrouve perdu dans des problèmes qui me semblent basiques...
Bref, j'ai repris la méthode de Databind d'une gridview sur le site de microsoft et j'ai remplacer certaines choses.
ça donne ceci:
Pour la partie Default.aspx:
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
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 sing System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; namespace WebApplication2 { public partial class _Default : System.Web.UI.Page { void Page_Load(Object sender, EventArgs e) { // This example uses Microsoft SQL Server and connects // to the Test sample database. The data source needs // to be bound to the GridView control only when the // page is first loaded. Thereafter, the values are // stored in view state. if (!IsPostBack) { // Declare the query string. String queryString = "Select * From WBDT_DT_TICKET"; // Run the query and bind the resulting DataSet // to the GridView control. DataSet ds = GetData(queryString); if (ds.Tables.Count > 0) { GvTA.DataSource = ds; GvTA.DataBind(); } else { } } } DataSet GetData(String queryString) { // Retrieve the connection string stored in the Web.config file. String connectionString = ConfigurationManager.ConnectionStrings["Test"].ConnectionString; DataSet ds = new DataSet(); try { // Connect to the database and run the query. SqlConnection connection = new SqlConnection(connectionString); SqlDataAdapter adapter = new SqlDataAdapter(queryString, connection); // Fill the DataSet. adapter.Fill(ds); } catch { } return ds; } } }
Je me retrouve avec une erreur qui me dit qu'il n'est pas nécessaire d'avoir "GvTA.DataSource = ds" et "GvTA.DataBind();".
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
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 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._Default" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Page sans titre</title> </head> <body bgcolor="white"> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="GESTION DES ARRETS DES POSTES DE FABRICATION" ForeColor="#FF8000"></asp:Label><br /> <br /> <cc1:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" Height="544px" Width="848px"><cc1:TabPanel runat="server" HeaderText="Arrêt" ID="TabPanel1"> <ContentTemplate> <br /><asp:Label ID="lblRech" runat="server" ForeColor="Highlight" Text="Fonction de recherche:"></asp:Label> <br /><br /><asp:Label ID="lblPoste" runat="server" Text="Poste:"></asp:Label> <asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList><br /><br /> <asp:Label ID="lvlDef" runat="server" Text="Définir une période:"></asp:Label> <br /><br /> <asp:Label ID="lblDu" runat="server" Text="Du:"></asp:Label> <asp:TextBox ID="txtDate1" runat="server"></asp:TextBox> <asp:Label ID="lblAu" runat="server" Text="au:"></asp:Label> <asp:TextBox ID="txtDate2" runat="server"></asp:TextBox> <cc1:CalendarExtender ID="CE1" runat="server" Enabled="True" TargetControlID="txtDate1"></cc1:CalendarExtender> <cc1:CalendarExtender ID="CE2" runat="server" Enabled="True" TargetControlID="txtDate2"></cc1:CalendarExtender> <br /><asp:Label ID="lblTA" runat="server" Font-Italic="True" ForeColor="Highlight" Text="Liste des tickets d'arrêt:"></asp:Label> <br /><br /> <asp:GridView ID="GvTA" AllowSorting="true" AllowPaging="true" Runat="server" DataSourceID="SqlDataSource1" AutoGenerateEditButton="true" DataKeyNames="ID_Ticket" AutoGenerateColumns="False"> <Columns> <asp:BoundField ReadOnly="true" HeaderText="ID_Ticket" DataField="ID_ticket" SortExpression="ID_ticket" /> <asp:BoundField HeaderText="Type Ticket" DataField="TicketTypeCode" SortExpression="TicketTypeCode" /> <asp:BoundField HeaderText="Type Maintenance" DataField="MaintenanceTypeCode" SortExpression="MaintenanceTypeCode" /> <asp:BoundField HeaderText="Date" DataField="DateTime" SortExpression="DateTime" /> <asp:BoundField HeaderText="Status" DataField="EventCode" SortExpression="EventCode" /> <asp:BoundField HeaderText="ID Assigné" DataField="AssigneUserID" SortExpression="AssigneUserID" /> <asp:BoundField HeaderText="Poste" DataField="WorkBench" SortExpression="WorkBench" /> <asp:BoundField HeaderText="Sous Poste" DataField="WorkBenchDiv" SortExpression="WorkBenchDiv" /> <asp:BoundField HeaderText="Code Priorité" SortExpression="SeverityDTCode" DataField="SeverityDTCode" /> <asp:BoundField HeaderText="Code Evénementiel" DataField="EventCode" SortExpression="EventCode" /> <asp:BoundField HeaderText="Statut" DataField="DTStatus" SortExpression="DTStatus" /> <asp:BoundField HeaderText="Poste" DataField="WorkBench" SortExpression="WorkBench" /> <asp:BoundField HeaderText="Commentaire" DataField="TicketComment" SortExpression="TicketComment" /> <asp:CheckBoxField HeaderText="Email" SortExpression="EmailFollowing" DataField="EmailFollowing" /> <asp:BoundField HeaderText="ID utilisateur session" DataField="SessionUserID" SortExpression="SessionUserID" /> <asp:BoundField HeaderText="Value Stream" DataField="WBVS" SortExpression="WBVS" /> <asp:BoundField HeaderText="Cellule" SortExpression="WBCELL" DataField="WBCELL" /> <asp:BoundField HeaderText="Raison d'annulation" DataField="CancelReasonCode" SortExpression="CancelReasonCode" /> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" Runat="server" SelectCommand="SELECT * FROM WBDT_DT_TICKET" ConnectionString="<%$ ConnectionStrings:Test %>" /> <asp:Label ID="lblCrea" runat="server" Font-Italic="True" ForeColor="Highlight" Text="Création d'un tickets d'arrêt:"></asp:Label> <br /><br /><asp:Label ID="lblVS" runat="server" Text="VS:"></asp:Label> <asp:TextBox ID="txtVS" runat="server"></asp:TextBox> <br /><asp:Label ID="lblCell" runat="server" Text="Cellule:"></asp:Label> <asp:TextBox ID="txtCell" runat="server"></asp:TextBox> <br /> <asp:Label ID="lblPosteCrea" runat="server" Text="Poste:"></asp:Label> <asp:TextBox ID="txtPoste" runat="server"></asp:TextBox> <asp:Button id="btnValider" runat="server" Text="Valider"></asp:Button> <cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></cc1:ToolkitScriptManager> </ContentTemplate> </cc1:TabPanel> <cc1:TabPanel runat="server" HeaderText="Intervention" ID="TabPanel2"></cc1:TabPanel> <cc1:TabPanel runat="server" HeaderText="Planification" ID="TabPanel3"></cc1:TabPanel> <cc1:TabPanel runat="server" HeaderText="Administration" ID="TabPanel4"></cc1:TabPanel> </cc1:TabContainer> </div> </form> </body> </html>
Qu'un seul des deux suffit, bien sur si j'en enlève un, ça ce lance mais j'ai pas de gridview.
Je suis un peut complétement paumé XD
Je sais même pas si le reste est correctement écrit en faite, donc je veux bien un avis global sur ce qui ne va pas.
Merci d'avance.
Partager