Checkboxes in DataGrid are not submitting a value

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
 
S

Steven Cheng[MSFT]

Hi Deeshubby76,

Welcome to MSDN newsgroup.
Regarding on the problem you mentioned, I'm thinking it should be a page
specific issue. How many pages in your application suffer this problem? As
for the http headers and data you posted, the different between the two
page request are the Post Data's form format. Generally there're two form
formats:

The default value for this attribute is
"application/x-www-form-urlencoded". (mapped to your second http
message....) and another is "multipart/form-data" which should be used in
combination with the INPUT element, type="file". (mapped to your first http
message...)

So I don't think this is the cause since the first style http message( form
data are separated...) is caused by therer'e some file upload element in
the page ,yes?

If convenient, I'd suggest you try creating a simple test page (with some
dummy data records...) which can reproduce the behavior so that we can
perform some tests on local side.

If there're anything unclear, please feel free to post here.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



--------------------
| Thread-Topic: Checkboxes in DataGrid are not submitting a value
| thread-index: AcX1LZihU0P5oAUdTkO1XOYB/HBZUw==
| X-WBNR-Posting-Host: 198.134.51.14
| From: "=?Utf-8?B?YnJpYW4=?=" <[email protected]>
| Subject: Checkboxes in DataGrid are not submitting a value
| Date: Tue, 29 Nov 2005 13:41:03 -0800
| Lines: 72
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet.datagridcontrol:14821
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
|
| 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")).Checke
d == 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"
|
dDwtMTQzMzM1NjcxNzt0PDtsPGk8MT47PjtsPHQ8cDxsPGVuY3R5cGU7PjtsPG11bHRpcGFydC9m
b3JtLWRhdGE7Pj47bDxpPDE+O2k8Mj47aTw0PjtpPDY47PjtsPHQ8cDxsPGVuY3R5cGU7PjtsPG1
1bHRpcGFydC9mb3JtLWRhdGE7Pj47bDxpP
|
| 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=dDwtMTgzNDQzMzg1ODt0PDtsPGk8MT47
PjtsPHQ8O2w8aTwwPjtpPDE%2BO2k8Mj47aTw0PjtpPDU%2BO2k8Nj47aTw3Pjs%2BO2w8dDw7bD
xpPDE%2BO2k8NT47aTw3Pjs%2BO2w8dDw7bDxpPDE%2BO2k8Mz47aTw1Pjs%2BO2w8dDxwPGw8VG
V4dDs%2BO2w8MHB4Oz4%2BOzs%2BO3Q8cDxsPFRleHQ7PjtsPHZpc2libGU7Pj47Oz47dDxwPGw8
VGV4dDs%2BO2w8bG9jYWwgd2ViIC8gbG9jYWwgZGF0YTs%2BPjs7Pjs%2BPjt0PHA8bDxUZXh0Oz
47bDxBZG1pbkhlYWRlcjFfVGl0bGVQYW5lbDs%2BPjs7Pjt0PHA8bDxUZXh0Oz47bDxkb2N1bWVu
dC50aXRsZTs%2BPjs7Pjs%2BPjt0PDtsPGk8MT47aTwzPjtpPDU%2BO2w8Y2hrRXhwYW5kUm9sZX
M7ZGdVc2VyUm9sZXM6X2N0bDI6Y2hrRGVsZXRlO2RnVXNlclJvbGVzOl9jdGwzOmNoa0RlbGV0ZT
tkZ1VzZXJSb2xlczpfY3RsNDpjaGtEZWxldGU7ZGdVc2VyUm9sZXM6X2N0bDU6Y2hrRGVsZXRlO2
RnVXNlclJvbGVzOl9jdGw2OmNoa0RlbGV0ZTs%2BPmHx5byap%2F%2FVZcP4113OmjIZ34tI&Adm
inMenu1%3ASiteDropDownList=0&AdminMenu1%3AProgramDropDownList=0&DropDownGran
tRole=Choose+a+Role%3A&btnDeleteCheckedRoles=DELETE+CHECKED+ITEMS&dgUserRole
s%3A_ctl2%3AchkDelete=on&dgUserRoles%3A_ctl3%3AchkDelete=on&dgUserRoles%3A_c
tl4%3AchkDelete=on
|
 
B

brian

Steven,

You are correct! I forgot about the INPUT type=file control which is present
on the well-behaving page. Good catch. At least this explains the difference
in headers between the well-behaved vs. non-functional pages.

Another detail that I would like to mention is that both pages have a region
on the right-hand side that allows for user-input, and upon submit, that
input is added into the database, then I call BindData() and the dataGrid is
updated with the new record. This part is working fine on both pages. So,
it's not as though one form works perfectly and the other doesn't work at
all. Just the checkboxes are not getting processed for the one dataGrid.

I'll do some further testing to see if I can reproduce the problem I'm
having and will share my results.
Thanks again for your prompt reply.

Brian
 
B

brian

Okay, below are two code snippets, one from the aspx page, and another from
the code-behind (aspx.cs).

Here's the dataGrid HTML/ASPX code
(not shown: aspx button control which executes a deletion routine in the
code-behind):

*************
SNIPPET #1
*************
<asp:datagrid id="dgUserRoles" runat="server" BorderColor="#E7E7FF"
BorderStyle="None" BorderWidth="1px"
BackColor="White" CellPadding="3" GridLines="Horizontal"
AutoGenerateColumns="False">
<FooterStyle ForeColor="#4A3C8C" BackColor="#B5C7DE"></FooterStyle>
<SelectedItemStyle Font-Bold="True" ForeColor="#F7F7F7"
BackColor="#738A9C"></SelectedItemStyle>
<AlternatingItemStyle BackColor="#F7F7F7"></AlternatingItemStyle>
<ItemStyle ForeColor="#4A3C8C" BackColor="#E7E7FF"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#F7F7F7"
BackColor="#4A3C8C"></HeaderStyle>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox id="chkDelete" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn Visible="False" DataField="UserRoles_id"
SortExpression="UserRoles_id" HeaderText="UserRoles ID"></asp:BoundColumn>
<asp:BoundColumn Visible="False" DataField="Roles_id"
SortExpression="Roles_id" HeaderText="Roles ID"></asp:BoundColumn>
<asp:BoundColumn Visible="False" DataField="Users_id"
SortExpression="Users_id" HeaderText="Users ID"></asp:BoundColumn>
<asp:BoundColumn DataField="RoleName" SortExpression="RoleName"
HeaderText="Role"></asp:BoundColumn>
<asp:BoundColumn Visible="False" DataField="PermissionName"
SortExpression="PermissionName" HeaderText="Permission"></asp:BoundColumn>
<asp:BoundColumn Visible="False" DataField="Permissions_id"
SortExpression="Permissions_id" HeaderText="Permission ID"></asp:BoundColumn>
</Columns>
<PagerStyle HorizontalAlign="Right" ForeColor="#4A3C8C"
BackColor="#E7E7FF" Mode="NumericPages"></PagerStyle>
</asp:datagrid>
*************
END SNIPPET
*************

Okay, when you click the delete button, this is the click event which fires.
When I step through the debugger, no errors are thrown, but chbox.Checked
never evaluates to "true" either, even when all the checkboxes are checked:
*************
SNIPPET #2
*************
private void btnDeleteCheckedRoles_Click(object sender, System.EventArgs e)
{
int ctr=0;
int ctr2=0;
System.Web.UI.WebControls.CheckBox chbox;
foreach(System.Web.UI.WebControls.DataGridItem dgi in this.dgUserRoles.Items)
{

chbox = ((System.Web.UI.WebControls.CheckBox)dgi.FindControl("chkDelete"));
if(chbox.Checked == true)
{
//delete from database by passing record id into a function (returns a
boolean)
if(this.deleteRole(Convert.ToInt32(dgi.Cells[1].Text)))
ctr++;
else
ctr2++;
}


}
this.YellowSticky1.Notify("Deleted " + ctr.ToString() + " role(s)
successfully." + this.errorMsg);
this.BindGrid();
}
***********
END SNIPPET
***********

thanks in advance for your help.

Brian
 
B

brian

I was just looking at my page_load event and noticed a unqualified call to
BindGrid() which must've been rebuilding the dataGrid state and throwing away
the viewstate version before processing the button Click event. I did not
share my page_load code in any of the previous posts, but that seems to be
part of my problem.

Thanks again for your time, Steven.

Brian

brian said:
Okay, below are two code snippets, one from the aspx page, and another from
the code-behind (aspx.cs).

Here's the dataGrid HTML/ASPX code
(not shown: aspx button control which executes a deletion routine in the
code-behind):

*************
SNIPPET #1
*************
<asp:datagrid id="dgUserRoles" runat="server" BorderColor="#E7E7FF"
BorderStyle="None" BorderWidth="1px"
BackColor="White" CellPadding="3" GridLines="Horizontal"
AutoGenerateColumns="False">
<FooterStyle ForeColor="#4A3C8C" BackColor="#B5C7DE"></FooterStyle>
<SelectedItemStyle Font-Bold="True" ForeColor="#F7F7F7"
BackColor="#738A9C"></SelectedItemStyle>
<AlternatingItemStyle BackColor="#F7F7F7"></AlternatingItemStyle>
<ItemStyle ForeColor="#4A3C8C" BackColor="#E7E7FF"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#F7F7F7"
BackColor="#4A3C8C"></HeaderStyle>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox id="chkDelete" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn Visible="False" DataField="UserRoles_id"
SortExpression="UserRoles_id" HeaderText="UserRoles ID"></asp:BoundColumn>
<asp:BoundColumn Visible="False" DataField="Roles_id"
SortExpression="Roles_id" HeaderText="Roles ID"></asp:BoundColumn>
<asp:BoundColumn Visible="False" DataField="Users_id"
SortExpression="Users_id" HeaderText="Users ID"></asp:BoundColumn>
<asp:BoundColumn DataField="RoleName" SortExpression="RoleName"
HeaderText="Role"></asp:BoundColumn>
<asp:BoundColumn Visible="False" DataField="PermissionName"
SortExpression="PermissionName" HeaderText="Permission"></asp:BoundColumn>
<asp:BoundColumn Visible="False" DataField="Permissions_id"
SortExpression="Permissions_id" HeaderText="Permission ID"></asp:BoundColumn>
</Columns>
<PagerStyle HorizontalAlign="Right" ForeColor="#4A3C8C"
BackColor="#E7E7FF" Mode="NumericPages"></PagerStyle>
</asp:datagrid>
*************
END SNIPPET
*************

Okay, when you click the delete button, this is the click event which fires.
When I step through the debugger, no errors are thrown, but chbox.Checked
never evaluates to "true" either, even when all the checkboxes are checked:
*************
SNIPPET #2
*************
private void btnDeleteCheckedRoles_Click(object sender, System.EventArgs e)
{
int ctr=0;
int ctr2=0;
System.Web.UI.WebControls.CheckBox chbox;
foreach(System.Web.UI.WebControls.DataGridItem dgi in this.dgUserRoles.Items)
{

chbox = ((System.Web.UI.WebControls.CheckBox)dgi.FindControl("chkDelete"));
if(chbox.Checked == true)
{
//delete from database by passing record id into a function (returns a
boolean)
if(this.deleteRole(Convert.ToInt32(dgi.Cells[1].Text)))
ctr++;
else
ctr2++;
}


}
this.YellowSticky1.Notify("Deleted " + ctr.ToString() + " role(s)
successfully." + this.errorMsg);
this.BindGrid();
}
***********
END SNIPPET
***********

thanks in advance for your help.

Brian
 
S

Steven Cheng[MSFT]

Thanks for your followup Brain,

So after you remove the unexpected "DataBind" function call in Page_Load ,
did the DataGrid worked well now? If there're still any questions or
anything need help, please feel free to post here.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| Thread-Topic: Feeling Stupid Now
| thread-index: AcX11NdnouSMqBB0TeCGT8MnfuQXYQ==
| X-WBNR-Posting-Host: 198.134.51.12
| From: "=?Utf-8?B?YnJpYW4=?=" <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Subject: Feeling Stupid Now
| Date: Wed, 30 Nov 2005 09:38:14 -0800
| Lines: 97
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet.datagridcontrol:14830
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridcontrol
|
| I was just looking at my page_load event and noticed a unqualified call
to
| BindGrid() which must've been rebuilding the dataGrid state and throwing
away
| the viewstate version before processing the button Click event. I did not
| share my page_load code in any of the previous posts, but that seems to
be
| part of my problem.
|
| Thanks again for your time, Steven.
|
| Brian
|
| "brian" wrote:
|
| > Okay, below are two code snippets, one from the aspx page, and another
from
| > the code-behind (aspx.cs).
| >
| > Here's the dataGrid HTML/ASPX code
| > (not shown: aspx button control which executes a deletion routine in
the
| > code-behind):
| >
| > *************
| > SNIPPET #1
| > *************
| > <asp:datagrid id="dgUserRoles" runat="server" BorderColor="#E7E7FF"
| > BorderStyle="None" BorderWidth="1px"
| > BackColor="White" CellPadding="3" GridLines="Horizontal"
| > AutoGenerateColumns="False">
| > <FooterStyle ForeColor="#4A3C8C" BackColor="#B5C7DE"></FooterStyle>
| > <SelectedItemStyle Font-Bold="True" ForeColor="#F7F7F7"
| > BackColor="#738A9C"></SelectedItemStyle>
| > <AlternatingItemStyle BackColor="#F7F7F7"></AlternatingItemStyle>
| > <ItemStyle ForeColor="#4A3C8C" BackColor="#E7E7FF"></ItemStyle>
| > <HeaderStyle Font-Bold="True" ForeColor="#F7F7F7"
| > BackColor="#4A3C8C"></HeaderStyle>
| > <Columns>
| > <asp:TemplateColumn>
| > <ItemTemplate>
| > <asp:CheckBox id="chkDelete" runat="server"></asp:CheckBox>
| > </ItemTemplate>
| > </asp:TemplateColumn>
| > <asp:BoundColumn Visible="False" DataField="UserRoles_id"
| > SortExpression="UserRoles_id" HeaderText="UserRoles
ID"></asp:BoundColumn>
| > <asp:BoundColumn Visible="False" DataField="Roles_id"
| > SortExpression="Roles_id" HeaderText="Roles ID"></asp:BoundColumn>
| > <asp:BoundColumn Visible="False" DataField="Users_id"
| > SortExpression="Users_id" HeaderText="Users ID"></asp:BoundColumn>
| > <asp:BoundColumn DataField="RoleName" SortExpression="RoleName"
| > HeaderText="Role"></asp:BoundColumn>
| > <asp:BoundColumn Visible="False" DataField="PermissionName"
| > SortExpression="PermissionName"
HeaderText="Permission"></asp:BoundColumn>
| > <asp:BoundColumn Visible="False" DataField="Permissions_id"
| > SortExpression="Permissions_id" HeaderText="Permission
ID"></asp:BoundColumn>
| > </Columns>
| > <PagerStyle HorizontalAlign="Right" ForeColor="#4A3C8C"
| > BackColor="#E7E7FF" Mode="NumericPages"></PagerStyle>
| > </asp:datagrid>
| > *************
| > END SNIPPET
| > *************
| >
| > Okay, when you click the delete button, this is the click event which
fires.
| > When I step through the debugger, no errors are thrown, but
chbox.Checked
| > never evaluates to "true" either, even when all the checkboxes are
checked:
| > *************
| > SNIPPET #2
| > *************
| > private void btnDeleteCheckedRoles_Click(object sender,
System.EventArgs e)
| > {
| > int ctr=0;
| > int ctr2=0;
| > System.Web.UI.WebControls.CheckBox chbox;
| > foreach(System.Web.UI.WebControls.DataGridItem dgi in
this.dgUserRoles.Items)
| > {
| >
| > chbox =
((System.Web.UI.WebControls.CheckBox)dgi.FindControl("chkDelete"));
| > if(chbox.Checked == true)
| > {
| > //delete from database by passing record id into a function (returns
a
| > boolean)
| > if(this.deleteRole(Convert.ToInt32(dgi.Cells[1].Text)))
| > ctr++;
| > else
| > ctr2++;
| > }
| >
| >
| > }
| > this.YellowSticky1.Notify("Deleted " + ctr.ToString() + " role(s)
| > successfully." + this.errorMsg);
| > this.BindGrid();
| > }
| > ***********
| > END SNIPPET
| > ***********
| >
| > thanks in advance for your help.
| >
| > Brian
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top