PC Review


Reply
Thread Tools Rate Thread

Accessing CheckBox when canceling edit

 
 
tshad
Guest
Posts: n/a
 
      29th Sep 2009
I am trying to find a way to access a checkbox after the Cancel button is
pressed during inline editing of a GridView.

<asp:TemplateField HeaderText="Reviewed"
ItemStyle-CssClass="alignCenter" SortExpression="Reviewed" Visible="True">
<ItemTemplate >
<asp:CheckBox ID="chkReviewed" runat="server"
OnCheckedChanged="chkReviewed_CheckChanged"
AutoPostBack="True"/></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblReviewed" runat="server" Text='<%# Eval("Reviewed")
== DBNull.Value ? "No" : Convert.ToBoolean(Eval("Reviewed")) ? "Yes" : "No"
%>'></asp:Label>
</EditItemTemplate>
</asp:TemplateField>

The problem is that if the chkReviewed is not checked, it will not be
checked if the user pressed the Canel button after editing the line.

I need to set the checkBox regardless of whether the user pressed the Update
or the Cancel button.

I tried the onCancelingEdit event, but it only allows me access to the
objects that were on the row during editing. In this case, that would be
the lblReviewed object and not the chkReviewed object.

Is there a way to know which row was edited during cancellation that would
give me access to the chkReviewed button before it is displayed so I can
check it?

Thanks,

Tom



 
Reply With Quote
 
 
 
 
tshad
Guest
Posts: n/a
 
      29th Sep 2009
I tried to make the change in onRowEditing which still shows me the
checkBox.

public void GridView1_RowEditing(object sender, GridViewEditEventArgs
e)
{
SqlDataReader dbReader = null;
SqlParameter retValue;
CheckBox checkBox;

GridViewRow gvr = (GridViewRow)GridView1.Rows[e.NewEditIndex];
checkBox = (CheckBox)gvr.FindControl("chkReviewed");
checkBox.Checked = true;

But it must not actually save it at this point, since when I go back (after
hitting Cancel) it is still unchecked.

Tom

"tshad" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I am trying to find a way to access a checkbox after the Cancel button is
>pressed during inline editing of a GridView.
>
> <asp:TemplateField HeaderText="Reviewed"
> ItemStyle-CssClass="alignCenter" SortExpression="Reviewed" Visible="True">
> <ItemTemplate >
> <asp:CheckBox ID="chkReviewed" runat="server"
> OnCheckedChanged="chkReviewed_CheckChanged"
> AutoPostBack="True"/></asp:Label>
> </ItemTemplate>
> <EditItemTemplate>
> <asp:Label ID="lblReviewed" runat="server" Text='<%# Eval("Reviewed")
> == DBNull.Value ? "No" : Convert.ToBoolean(Eval("Reviewed")) ? "Yes" :
> "No" %>'></asp:Label>
> </EditItemTemplate>
> </asp:TemplateField>
>
> The problem is that if the chkReviewed is not checked, it will not be
> checked if the user pressed the Canel button after editing the line.
>
> I need to set the checkBox regardless of whether the user pressed the
> Update or the Cancel button.
>
> I tried the onCancelingEdit event, but it only allows me access to the
> objects that were on the row during editing. In this case, that would be
> the lblReviewed object and not the chkReviewed object.
>
> Is there a way to know which row was edited during cancellation that would
> give me access to the chkReviewed button before it is displayed so I can
> check it?
>
> Thanks,
>
> Tom
>
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating an Edit Checkbox bp Microsoft Access 1 26th Jun 2009 11:21 PM
Datagridview edit row with checkbox rgparkins Microsoft ASP .NET 2 5th Oct 2007 01:33 PM
Accessing an HTML Checkbox Craig Andrews Microsoft ASP .NET 9 17th Dec 2004 04:45 PM
datagrid checkbox edit Mike P Microsoft ASP .NET 0 8th Apr 2004 04:59 PM
Re: accessing CheckBox on Worksheet Mike Tomasura Microsoft Excel Programming 4 24th Jul 2003 01:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:15 PM.