System.ArgumentOutOfRangeException then add data to DataTable

Hello!

I use DataTable and AngleSharp.

Shows error while adding data to DataTable (below). Although there is no such error when using the standard VS DataGridView.What could be the problem?

System.ArgumentOutOfRangeException: The specified argument is out of range.Parameter name: index at AngleSharp.Common.ObjectExtensions.GetItemByIndex [T] (IEnumerable`1 items, Int32 index) at AngleSharp.Dom.HtmlCollection`1.get_Item (Int32 index)


My code:

private void Form1_Load(object sender, EventArgs e)

{

dt.Columns.Add("Ip", Type.GetType("System.String"));

dt.Columns.Add("Port", Type.GetType("System.String"));

dt.Columns.Add("Country", Type.GetType("System.String"));

dt.Columns.Add("Anonymity", Type.GetType("System.String"));

dt.Columns.Add("Google", Type.GetType("System.String"));

dt.Columns.Add("Https", Type.GetType("System.String"));

proxyGrid.ShowRowHeader = true;

proxyGrid.AllowFiltering = true;

proxyGrid.DataSource = dt;

}


async Task StartCrawl()

{

try

{

var config = Configuration.Default.WithDefaultLoader().WithCss().WithJs();

var address = "url";

var context = BrowsingContext.New(config);

var document = await context.OpenAsync(address);

var trs = document.QuerySelectorAll(".table-responsive tbody tr");

foreach (var item in trs)

{

if (item != null)

{

var tds = item.QuerySelectorAll("td");

if (tds != null)

{

dt.Rows.Add(new object[]

{

tds[0].TextContent,

tds[1].TextContent,

tds[3].TextContent,

tds[4].TextContent,

tds[5].TextContent,

tds[6].TextContent,

});

}


}

}

}

catch (Exception ex)

{

MessageBox.Show(ex.ToString());

}

finally

{

MessageBox.Show("Collect");

}

}


The problem has been resolved. Edited QuerySelector. True, it remained unclear why this did not occur in the standard DataGridView


Thanks


1 Reply

VS Vijayarasan Sivanandham Syncfusion Team August 19, 2021 12:15 PM UTC

Hi Slava,

Thank you for contacting Syncfusion Support. 
Provided details are insufficient to find the exact cause for the issue. Can you please provide the more information related to your query? 
Can you please share us below things?        
        1. Provide the stack trace details of the exception occurred in your application. 
        2. Provide replication procedure with video illustration of the reported issue 
        3. If possible, kindly provide a simple issue reproducible 
It will be helpful for us to check on it and provide you the solution at the earliest. 
Regards, 
Vijayarasan S 


Loader.
Up arrow icon