What is an efficient way of setting the page of an ASP.net GridView to the page containing a given row? -
I have a web page with ASP.net GridView (with paging) Grid view has more than 10,000 rows in each row The "id" field is there.
It's a big size, but suppose I want the user to type an arbitrary line ID in a text field and take it to the gridview with the page index
I Have tried the following, but it does not work:
DataSet ds = ReportManager.GetDevices (AdHocQuery); LblRecordCount.Text = String.Format ("{0: #, 0}", DTTables [0] .Rows.Count); String sort direction = ADHQAction. STDERAction == "descending"? "DESC": "ASC"; DataView DV = new data view (DSTibles [0], string.opti, adhoccorry.centralomainam + "+ Sort Directions, DataviverRotateContentRO); GvAsset.DataSource = DV; If there is a device ID, change the page to the page containing the given ID. (! String.IsNullOrEmpty (DeviceId)) {// First of all, the given device ID line row number = 0; Int i; (I = {DataRow row = dv.Table.Rows [i]; If (row.Field & lt; Guid) for 0; i & lt; dv.Table.Rows.Count; i ++) & Gt; ("deviceId") ToString (.) ToUpper () == DeviceId.ToUpper ()) {rowNumber = i; breakdown;}} // page index row number is being divided by page size Example For, if the page size is 10 ... // row 5 is on page 0, // row 15 is on page 1, // line is 28 page 2, and therefore int page index = rowNumber / gvAsset.PageSize; GvAsset.PageIndex = Page Index; This code compiles, but it constantly shows the wrong page of Gridview.
How can I code this right Show page?
I believe you need to call databand () to make a change in the PageIndex property .
Comments
Post a Comment