I have an aspx page including three HTML tables. One of the tables in HTML is shown below:
<table id='example' >
<thead>
<tr>
<th><INPUT type="checkbox" onchange="checkAll(this)" name="chk[]"/></th>
<th>SchoolID</th>
...
</tr>
</thead>
<tr>
<td>
<input type='checkbox' name='name0' />
</td>
<td>200116</td>
</tr>
<tr>
<td>
<input type='checkbox' name='name1' />
</td>
<td>200116</td>
</tr>
...
</table>
This table looks like:
What I need is to get the SchoolID for the rows that are checked by the end-user in C#. What is the best way to do that?
I am currently trying to use HTMLAgilityPack to get my HTML table as Datatable, but I am not successful. It is getting the first table, I need the third one. And yet, I am not sure if it is the best way. Please advise.
var doc = new HtmlDocument();
//doc.Load(Request.Url.ToString()); //gives error.
doc.Load(filepath); //this works
//this is returning me the first table of my page, i need the third table.
var nodes = doc.DocumentNode.SelectNodes("//table/tr");
var table = new DataTable("exampleDataTable");
Any help would be so appreciated!
EDIT: Turned out I cannot use HTMLAgilityPack since I am actually creating the table in C# then sending to front-end. Using filepath is not working because there is no table in the .aspx file by default.
EDIT2: Sec, there is web.load function I have found, maybe I can use Request.Url.

valueattribute to the checkboxes whose value is the same as the School ID. Then, when they are submitted with the form, you'll have the values of the checked items. You may want to name them all something likechosenSchoolId[]so that you get an array in your action.