The main problem is that when using webclent to obtain the page source code, when the page contains datagrid and the control uses its own paging function, the normal method can only obtain the data of the first page and the data of other pages.
If you can't get it, here is the solution.
Method one:
The main idea is to use webclient to post data to the service to obtain data. Here we mainly use a small tool to analyze the composition and running process of the page. During the analysis, we found that when the next page is clicked, three parameters will be posted.
They are: __EVENTTARGET, __EVENTARGUMENT, __VIEWSTATE. Here, the __VIEWSTATE parameter is obtained when opening the first page of data, __EVENTTARGET is the name of the control to be called (can be obtained through httpwatch), __EVENTARGUMENT is the parameter when calling the event, the code is as follows:
string result="";
result = this.loadtop (" http://localhost/ProjectInfo.aspx?JOBNO1=2001-09110 ");
string vie = GetTagContent(result,"name="__VIEWSTATE" value="","" />");
vie=vie.Replace ("name="__VIEWSTATE" value="","");
vie=vie.Replace ("" />","");
WebClient a = new WebClient();
NameValueCollection na = new NameValueCollection();
na.Add("__EVENTTARGET","NewHouseGridModule1:ModuleSplitPage:lbnNextPage");
na.Add("__VIEWSTATE",vie);
byte [] ss = a.UploadValues(" http://localhost/ProjectInfo.aspx?JOBNO1=2001-09110","POST",na );
Encoding encode=Encoding .GetEncoding ("utf-8");
result=encode.GetString(ss);
Method 2:
Use the axWebBrowser control to download the first page, and then add the following code at the bottom:
<script language='javascript' type='text/javascript'>__doPostBack('NewHouseGridModule1$ModuleSplitPage$lbnNextPage','');</script>,
source: http://bccu.cnblogs.com/archive/2006/ 05/11/397382.html