B
brian
I am familiar with creating TemplateColumns in dataGrids which contain a
checkbox control. I have successfully implemented deletion routines, where,
upon a button_Click event, mulitple items are deleted from the dataGrid.
For example, this loop might be inside of my button_Click events:
foreach(System.Web.UI.WebControls.DataGridItem dgi in this.dgQuestions.Items)
{
if(((System.Web.UI.WebControls.CheckBox)dgi.FindControl("chkDelete")).Checked == true)
{
dgi.Visible = false;
ctr++;
}
}
However, I am currently baffled, as I am working on a dataGrid today, no
different than other dataGrids I've implemented elsewhere in the same web
application - and when I step through the code in the debugger, the
FindControl("chkDelete") is successful, but the .Checked property always
evaluates to False - no matter if I check every item in the grid.
I have installed ieHTTPHeaders v 1.6 into my MSIE to help me view the
headers being submitted. I have noticed a difference in how the two pages are
behaving...
On a dataGrid containing checked checkboxes which is working correctly, when
I submit the page, here is a sample of how the headers are formatted
(viewstate blob truncated a bit for brevity's sake):
************
************
Cookie: WebAdmin=5BED4; adminuser=watts;
ASP.NET_SessionId=lqahbc3cn4eqdsmklvdpityk
-----------------------------7d51afb2104e
Content-Disposition: form-data; name="__EVENTTARGET"
-----------------------------7d51afb2104e
Content-Disposition: form-data; name="__EVENTARGUMENT"
-----------------------------7d51afb2104e
Content-Disposition: form-data; name="__VIEWSTATE"
dDwtMTQzMzM1NjcxNzt0PDtsPGk8MT47PjtsPHQ8cDxsPGVuY3R5cGU7PjtsPG11bHRpcGFydC9mb3JtLWRhdGE7Pj47bDxpPDE+O2k8Mj47aTw0PjtpPDY47PjtsPHQ8cDxsPGVuY3R5cGU7PjtsPG11bHRpcGFydC9mb3JtLWRhdGE7Pj47bDxpP
Removed Checked Items
-----------------------------7d51afb2104e
Content-Disposition: form-data; name="dgQuestions:_ctl2:chkDelete"
on
-----------------------------7d51afb2104e
Content-Disposition: form-data; name="dgQuestions:_ctl3:chkDelete"
on
*************
*************
And now, for the badly behaving dataGrid, containing checked checkboxes.
Notice how it runs together the _EVENTSTATE, _EVENTTARGUEMENT and _VIEWSTATE
lines at the start of the viewstate blob, and runs together the check box
identifiers toward the end of the blob (middle of blob truncated for
brevity's sake):
*************
*************
Cookie: WebAdmin=5BED4; adminuser=watts;
ASP.NET_SessionId=lqahbc3cn4eqdsmklvdpityk
__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=dDwtMTgzNDQzMzg1ODt0PDtsPGk8MT47PjtsPHQ8O2w8aTwwPjtpPDE%2BO2k8Mj47aTw0PjtpPDU%2BO2k8Nj47aTw3Pjs%2BO2w8dDw7bDxpPDE%2BO2k8NT47aTw3Pjs%2BO2w8dDw7bDxpPDE%2BO2k8Mz47aTw1Pjs%2BO2w8dDxwPGw8VGV4dDs%2BO2w8MHB4Oz4%2BOzs%2BO3Q8cDxsPFRleHQ7PjtsPHZpc2libGU7Pj47Oz47dDxwPGw8VGV4dDs%2BO2w8bG9jYWwgd2ViIC8gbG9jYWwgZGF0YTs%2BPjs7Pjs%2BPjt0PHA8bDxUZXh0Oz47bDxBZG1pbkhlYWRlcjFfVGl0bGVQYW5lbDs%2BPjs7Pjt0PHA8bDxUZXh0Oz47bDxkb2N1bWVudC50aXRsZTs%2BPjs7Pjs%2BPjt0PDtsPGk8MT47aTwzPjtpPDU%2BO2w8Y2hrRXhwYW5kUm9sZXM7ZGdVc2VyUm9sZXM6X2N0bDI6Y2hrRGVsZXRlO2RnVXNlclJvbGVzOl9jdGwzOmNoa0RlbGV0ZTtkZ1VzZXJSb2xlczpfY3RsNDpjaGtEZWxldGU7ZGdVc2VyUm9sZXM6X2N0bDU6Y2hrRGVsZXRlO2RnVXNlclJvbGVzOl9jdGw2OmNoa0RlbGV0ZTs%2BPmHx5byap%2F%2FVZcP4113OmjIZ34tI&AdminMenu1%3ASiteDropDownList=0&AdminMenu1%3AProgramDropDownList=0&DropDownGrantRole=Choose+a+Role%3A&btnDeleteCheckedRoles=DELETE+CHECKED+ITEMS&dgUserRoles%3A_ctl2%3AchkDelete=on&dgUserRoles%3A_ctl3%3AchkDelete=on&dgUserRoles%3A_ctl4%3AchkDelete=on
checkbox control. I have successfully implemented deletion routines, where,
upon a button_Click event, mulitple items are deleted from the dataGrid.
For example, this loop might be inside of my button_Click events:
foreach(System.Web.UI.WebControls.DataGridItem dgi in this.dgQuestions.Items)
{
if(((System.Web.UI.WebControls.CheckBox)dgi.FindControl("chkDelete")).Checked == true)
{
dgi.Visible = false;
ctr++;
}
}
However, I am currently baffled, as I am working on a dataGrid today, no
different than other dataGrids I've implemented elsewhere in the same web
application - and when I step through the code in the debugger, the
FindControl("chkDelete") is successful, but the .Checked property always
evaluates to False - no matter if I check every item in the grid.
I have installed ieHTTPHeaders v 1.6 into my MSIE to help me view the
headers being submitted. I have noticed a difference in how the two pages are
behaving...
On a dataGrid containing checked checkboxes which is working correctly, when
I submit the page, here is a sample of how the headers are formatted
(viewstate blob truncated a bit for brevity's sake):
************
************
Cookie: WebAdmin=5BED4; adminuser=watts;
ASP.NET_SessionId=lqahbc3cn4eqdsmklvdpityk
-----------------------------7d51afb2104e
Content-Disposition: form-data; name="__EVENTTARGET"
-----------------------------7d51afb2104e
Content-Disposition: form-data; name="__EVENTARGUMENT"
-----------------------------7d51afb2104e
Content-Disposition: form-data; name="__VIEWSTATE"
dDwtMTQzMzM1NjcxNzt0PDtsPGk8MT47PjtsPHQ8cDxsPGVuY3R5cGU7PjtsPG11bHRpcGFydC9mb3JtLWRhdGE7Pj47bDxpPDE+O2k8Mj47aTw0PjtpPDY47PjtsPHQ8cDxsPGVuY3R5cGU7PjtsPG11bHRpcGFydC9mb3JtLWRhdGE7Pj47bDxpP
Removed Checked Items
-----------------------------7d51afb2104e
Content-Disposition: form-data; name="dgQuestions:_ctl2:chkDelete"
on
-----------------------------7d51afb2104e
Content-Disposition: form-data; name="dgQuestions:_ctl3:chkDelete"
on
*************
*************
And now, for the badly behaving dataGrid, containing checked checkboxes.
Notice how it runs together the _EVENTSTATE, _EVENTTARGUEMENT and _VIEWSTATE
lines at the start of the viewstate blob, and runs together the check box
identifiers toward the end of the blob (middle of blob truncated for
brevity's sake):
*************
*************
Cookie: WebAdmin=5BED4; adminuser=watts;
ASP.NET_SessionId=lqahbc3cn4eqdsmklvdpityk
__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=dDwtMTgzNDQzMzg1ODt0PDtsPGk8MT47PjtsPHQ8O2w8aTwwPjtpPDE%2BO2k8Mj47aTw0PjtpPDU%2BO2k8Nj47aTw3Pjs%2BO2w8dDw7bDxpPDE%2BO2k8NT47aTw3Pjs%2BO2w8dDw7bDxpPDE%2BO2k8Mz47aTw1Pjs%2BO2w8dDxwPGw8VGV4dDs%2BO2w8MHB4Oz4%2BOzs%2BO3Q8cDxsPFRleHQ7PjtsPHZpc2libGU7Pj47Oz47dDxwPGw8VGV4dDs%2BO2w8bG9jYWwgd2ViIC8gbG9jYWwgZGF0YTs%2BPjs7Pjs%2BPjt0PHA8bDxUZXh0Oz47bDxBZG1pbkhlYWRlcjFfVGl0bGVQYW5lbDs%2BPjs7Pjt0PHA8bDxUZXh0Oz47bDxkb2N1bWVudC50aXRsZTs%2BPjs7Pjs%2BPjt0PDtsPGk8MT47aTwzPjtpPDU%2BO2w8Y2hrRXhwYW5kUm9sZXM7ZGdVc2VyUm9sZXM6X2N0bDI6Y2hrRGVsZXRlO2RnVXNlclJvbGVzOl9jdGwzOmNoa0RlbGV0ZTtkZ1VzZXJSb2xlczpfY3RsNDpjaGtEZWxldGU7ZGdVc2VyUm9sZXM6X2N0bDU6Y2hrRGVsZXRlO2RnVXNlclJvbGVzOl9jdGw2OmNoa0RlbGV0ZTs%2BPmHx5byap%2F%2FVZcP4113OmjIZ34tI&AdminMenu1%3ASiteDropDownList=0&AdminMenu1%3AProgramDropDownList=0&DropDownGrantRole=Choose+a+Role%3A&btnDeleteCheckedRoles=DELETE+CHECKED+ITEMS&dgUserRoles%3A_ctl2%3AchkDelete=on&dgUserRoles%3A_ctl3%3AchkDelete=on&dgUserRoles%3A_ctl4%3AchkDelete=on