Answered by:
Show selected item in gridview

Question
-
User-513628628 posted
Hi all,
I read article : https://code.msdn.microsoft.com/Maintance-the-CheckBox-7b9e9e1e
But how can i get selected value in gridview ?
Anyone can help me out ?
Thank you very much !Wednesday, July 6, 2016 7:35 AM
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
- 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
- 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