My problem is:
I have a GridView, which is bound to list of declared DTO objects with column of CheckBoxes. Also, I have a “Save” button on the page. My mission concludes in getting all rows, where CheckBox is checked and get the containing data. Unfortunately, row.DataItem = null on Button1_Click, because, I’m using if(!IsPostBack) gw.DataBind() statement (otherwise, I can’t get CheckBox status). Could you give me the best practice for solving my problem?
Thank you in advance!
If you do
if(!IsPostBack) --> gw.DataBind(), that will reinitialize yourGridViewand the checkboxes will be set to unchecked again.In your case, in
Button1_Clickevent, you can loop through eachDataRowon yourGridViewand find the row which has it’s checkbox checked and get all the selected row data.