خرید بک لینک

Vote count: 0

I try to read data from text file and show this into GridView. But rows are added and all are empty (only first row is showing). Picture of GridViev Code:

 string data = File.ReadAllText(Server.MapPath("~/App_Data/TextFile1.txt"));
        string help = "";
        string imie = "";
        string nazwisko = "";
        string data_ur = "";
        string plec = "";
        long pesel = 0;
        int counter = 0;
        DataTable dt = new DataTable();
        dt.Columns.AddRange(new DataColumn[5] { new DataColumn("Imię", typeof(string)), new DataColumn("Nazwisko", typeof(string)), new DataColumn("Data urodzenia", typeof(string)), new DataColumn("Płeć", typeof(string)), new DataColumn("Pesel", typeof(long)) });
        for (int i = 0; i < data.Count(); i++)
        {
            if (data[i] != ' '&& data.Count()-1!=i)
            {
                help += data[i];
            }
            else
            {
                if (counter == 0)
                    imie = help;
                else
                    if (counter == 1)
                        nazwisko = help;
                    else
                        if (counter == 2)
                            data_ur = help;
                        else
                            if (counter == 3)
                                plec = help;
                            else
                            {
                                pesel = Int64.Parse(help);
                                dt.Rows.Add(imie,nazwisko,data_ur,plec,pesel);
                                counter = -1;
                            }
                counter++;
                help = "";
            }
        }
        GridView1.DataSource = dt;
        GridView1.DataBind();    

i try also this but nothing change: dt.Rows.Add("W", "w", "w", "w", 123);

asked 37 secs ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 2 ارديبهشت 1396 ساعت: 4:48

صفحه بندی