locked
Show selected item in gridview RRS feed

Answers

  • User-1377768212 posted

    Hi,

    Check the following comment in article.

    //According to the List<Bool> that been saved in ViewState to set the state of current row's CheckBox. 

    Based on the article, The check box value inserted into ViewState.

    Reference 

    http://www.c-sharpcorner.com/UploadFile/rohatash/how-to-get-the-selected-row-in-gridview-using-Asp-Net/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 6, 2016 8:13 AM
  • User1724605321 posted

    Hi pamyral_279,

    Code below is for your reference :

                isChecked = ViewState["CheckList"] as List<bool>;
                var dt = ViewState["dt"] as DataTable;
    for (int i = 0; i < isChecked.Count; i++) { if (isChecked[i] == true) { string ID = dt.Rows[i][0].ToString(); string Name = dt.Rows[i][1].ToString(); } }

    You could create a button click event to get all selected rows .

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 6, 2016 8:36 AM

All replies

  • User-1377768212 posted

    Hi,

    Check the following comment in article.

    //According to the List<Bool> that been saved in ViewState to set the state of current row's CheckBox. 

    Based on the article, The check box value inserted into ViewState.

    Reference 

    http://www.c-sharpcorner.com/UploadFile/rohatash/how-to-get-the-selected-row-in-gridview-using-Asp-Net/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 6, 2016 8:13 AM
  • User1724605321 posted

    Hi pamyral_279,

    Code below is for your reference :

                isChecked = ViewState["CheckList"] as List<bool>;
                var dt = ViewState["dt"] as DataTable;
    for (int i = 0; i < isChecked.Count; i++) { if (isChecked[i] == true) { string ID = dt.Rows[i][0].ToString(); string Name = dt.Rows[i][1].ToString(); } }

    You could create a button click event to get all selected rows .

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 6, 2016 8:36 AM