Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
private void button1_Click(object sender, EventArgs e)
        {
 

            DataTable tab = new DataTable();
            tab.Columns.Add("matricule", Type.GetType("System.Int32"));
            tab.Columns.Add("nom", Type.GetType("System.String"));
            tab.Columns.Add("part", Type.GetType("System.Int32"));
            for (int i = 0; i <= dg.Rows.Count - 1; i++)
            {
 
                DataRow dr = tab.NewRow();
                dr[0] = dg.Rows[i].Cells[0].Value;
                dr[1] = dg.Rows[i].Cells[1].Value;
                dr[2] = dg.Rows[i].Cells[2].Value;
                tab.Rows.Add(dr);
            }
 
                DataRow mdr = tab.NewRow();
                mdr[0] = t1.Text;
                mdr[1] = t2.Text;
                mdr[2] = t3.Text;
                tab.Rows.Add(mdr);
 

                dg.DataSource = tab;
            
           
        }
Bonjour
 
j'ai un probleme de chargement Data GridView sans base ,l’exécution me donne just un seule ligne si je veut ajouter un nouveau ligne ne se realise pas avec un erreur que je ne le sais pas .
 
merci pou l'aide
 
[Translation courtesy of Google translate:]
Hello
 
I have a problem loading GridView Data without basis, the execution gives me just a single line if I want to add a new line will not be realized with an error that I do not know.
 
thank you for your help
Posted 23-Mar-14 8:45am
Edited 23-Mar-14 9:04am
CHill6085.6K
v2
Comments
CHill60 at 23-Mar-14 14:04pm
   
Quel était le message d'erreur? What was the error message?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Il vous manque la liaison de données.
 
        private void Button1_Click(object sender, EventArgs e)
        {
            DataTable tab = new DataTable();
            tab.Columns.Add("matricule", Type.GetType("System.Int32"));
            tab.Columns.Add("nom", Type.GetType("System.String"));
            tab.Columns.Add("part", Type.GetType("System.Int32"));
            for (int i = 0; i <= dg.Rows.Count - 1; i++)
            {
 
                DataRow dr = tab.NewRow();
                dr[0] = dg.Rows[i].Cells[0].Text;
                dr[1] = dg.Rows[i].Cells[1].Text;
                dr[2] = dg.Rows[i].Cells[2].Text;
                tab.Rows.Add(dr);
            }
 
            DataRow mdr = tab.NewRow();
            mdr[0] = Server.HtmlEncode(t1.Text);
            mdr[1] = Server.HtmlEncode(t2.Text);
            mdr[2] = Server.HtmlEncode(t3.Text);
            tab.Rows.Add(mdr);
 
            dg.DataSource = tab;
            dg.DataBind();
        }
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web01 | 2.8.150327.1 | Last Updated 2 Apr 2014
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100