Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

I would like to create two columns and take some information from one html file. I can create the first column and I filled in the rows. I created the second column but I can't fill in the rows of the second column? Could you please help me?

Regards

What I have tried:

C#
string inner = doc.DocumentNode.SelectSingleNode("//a[@ class='a-link-normal s-access-detail-page  s-color-twister-title-link a-text-normal']").InnerText;
            var nodes = doc.DocumentNode.SelectNodes("//span[@ class='a-offscreen']");
            string[] s = new string[20];
            string[] ss = new string[20];
            string[] s1 = new string[500];
            string[] ss1 = new string[500];
            dataGridView2.ColumnCount = 2;
            dataGridView2.Columns[0].Name = "Price";
            dataGridView2.Columns[1].Name = "Name";

            dataGridView2.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            foreach(HtmlAgilityPack.HtmlNode item in nodes)
            {
                s[0] = item.InnerText;
       
                ss = (string[])s.ToArray();
                dataGridView2.Rows.Add(ss[0]);
                
                dataGridView2.Rows.Add(ss[0]);              

            }
Posted
Updated 25-Jun-18 20:55pm
v2

1 solution

All you have to do is to debug your code.
Take a look at your code - a reason seems to be quite obvious (see my comments):
foreach(HtmlAgilityPack.HtmlNode item in nodes)
{
    s[0] = item.InnerText;  
    ss = (string[])s.ToArray(); //unused variable
    dataGridView2.Rows.Add(ss[0]); //same as below
    dataGridView2.Rows.Add(ss[0]); //same as above              
}
 
Share this answer
 
v2
Comments
Richard Deeming 26-Jun-18 10:30am    
"edbug" your code? That's a new one on me. 😁
Maciej Los 26-Jun-18 13:38pm    
Spelling corrected ;)

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900