slt!
voilà, je voudrais mettre dans un gridview une suite de donnée recuillie dans une bd, le truc c'est que il n'affiche rien sur le grid view!
voilà le code: .aspx.cs:
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
public partial class gridview : System.Web.UI.Page
    {
        listarticle l = new listarticle();
        categorie c = new categorie();
 
        protected void Page_Load(object sender, EventArgs e)
        {
            int x; 
            x= c.id_cat(Request.Form["texte"].ToString());
            TextBox1.Text = x.ToString();
           affichage_data.DataSource = l.affichage_article(x);
 
           affichage_data.DataBind();
 
        }
    }
et voilà le code aspx:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="affichage_data" runat="server" AutoGenerateColumns="true">
                <
        </asp:GridView>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
 
    </div>
    </form>
</body>
nb: voilà le fonction appeller:
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
public  ArrayList affichage_article(int catid)
        {
            MySqlConnection conn = new MySqlConnection(global.connection);
            MySqlCommand cmd = new MySqlCommand();
            MySqlDataReader Dr;
            conn.Open();
 
            ArrayList liste;
 
            try
            {
 
                cmd.Connection = conn;
                cmd.CommandText = "Select article.id_article,id_categorie,introduction,titre,corps,date_redac,etat_article from  article inner join statut on article.id_article=statut.id_article where id_categorie="+catid+"";
                Dr = cmd.ExecuteReader();
 
                liste = new ArrayList();
                liste.Add("84984984");
 
                while (Dr.Read())
                {
 
                    article a = new article();
 
                    a.id_article = int.Parse(Dr["article.id_article"].ToString());
                    a.id_categorie = int.Parse(Dr["id_categorie"].ToString());
                    a.id_user = int.Parse(Dr["id_user"].ToString());
                    a.introduction=Dr["introduction"].ToString();
                    a.date_redac=DateTime.Parse(Dr["date_redac"].ToString());
                    a.titre = Dr["titre"].ToString();
                    a.statut=Dr["etat_statut"].ToString();
                    liste.Add(a);
 
                }
                return liste;
            }
            catch {  }
            finally { conn.Close(); }
            return null;
 
        }