6. Select data from client and get field value

Source: Internet
Author: User

1. Select or deselect all rows on the page
Using the Selectallrowsonpage method
Grammar 1:void Selectallrowsonpage ()
Syntax 2:void selectallrowsonpage (bool selected)
Parameter selected indicates that all rows are selected or deselected

2. Select or cancel the specified line or all rows
(1) Selectrows method (selects data based on the index of the row)
Grammar 1:void Selectrows ()
Select All records (including records that are not the current page)

Syntax 2:void selectrows (int visibleindex)
Select the specified row data, but before you have to set Keyfieldname, which is the Aspxgridview primary key

Syntax 3:void selectrows (int32[] visibleindces)
Select a specified number of rows of data

Syntax 4:void selectrows (int visibleindex,bool selected)
Selects or de-selects the specified data, and the parameter selected indicates that all rows are selected or deselected

Syntax 5:void selectrows (int32[] Visibleindces,bool selected)
Select or deselect the specified multiline data, and the parameter selected indicates that all rows are selected or deselected

Example: We want to check the 第1-10 row data in Aspxgridveiw

 var  rows = new   Array ();  for  (var  i = 0 ; i < 10 ; I++ = I;} Grid. Selectrows (rows);  //  Note: Grid is Aspxgridview client ID, not runat  


(2) Selectrowsbykey method (selects data based on the value of the primary key, provided that the primary key, or Keyfieldname property, must be set for Aspxgridview)
Syntax 1:void Selectrowsbykey (object key)
Select row data for the specified primary key value

Grammar 2:void Selectrowsbykey (object[] keys)
Select multiple rows of data for the specified primary key value collection

Syntax 3:void Selectrowsbykey (object key, bool selected);
Select or deselect row data for the specified primary key value, and the parameter selected indicates that all rows are selected or deselected

Grammar 4:void Selectrowsbykey (object[] keys, BOOL selected);
Selects or cancels the selection of multiple rows of data for the specified primary key value collection, and the parameter selected indicates that all rows are selected or deselected

3. Get the selected line information
(1) Gets the number of rows selected
Syntax: Int getselectedrowcount ()

(2) Gets the selected row field value
function getselectedfieldvalues (fieldnames:string,oncallback:aspxclientgridviewvaluescallback);
Example:

function Getselectedfieldvalues () {varFieldNames ="Logid"; Grid. Getselectedfieldvalues (FieldNames, getselectedfieldvalues_callback);} function Getselectedfieldvalues_callback (result) {varmsg=""; if(Result.length >0) {         for(vari =0; i < result.length; i++) {msg= msg +result[i].tostring (); }} alert (msg);}


Note : Many foreground values for Aspxgridview are performed in the callback function.

4. Cancel selection of all rows on the page
(1) Unselectallrowsonpage method
Syntax: void Unselectallrowsonpage ()

5. Cancel the selection of the specified line or all rows
(1) Unselectrowonpage method
Syntax: function unselectrowonpage (visibleindex:int);

(2) Unselectrows method (deselect data based on row index)
Syntax 1:void unselectrows ();//Cancel selection of all rows
Syntax 2:void unselectrows (int visibleindex);//cancels the selection of the specified row
Grammar 3:void unselectrows (int32[] visibleindices); Cancel the selection of a specified range of insiders

(3) Unselectrowsbykey method (deselect the data based on the value of the primary key, if the primary key must be set for Aspxgridview)
Grammar 1:void Unselectrowsbykey (object[] keys);
Syntax 2:void Unselectrowsbykey (object key);

This is the end of this section, please read the next section.

Source:. NET Learning Network
Description: All sources are . NET Learning Network articles are original, if reproduced, please mark this page address in the reprint, thank you!

6. Select data from client and get field value

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.