Home All Groups Group Topic Archive Search About

Problem editing checkbox template column

Author
1 Mar 2005 1:59 AM
Houston Lucifer
Hi all, i am having a problem with re-assigning the original value in the
checkbox when the datagrid is in edit mode. I have tried finding the control
using findcontrol method in the edit event but can't. I try to find the
control in the update event and i can do it. But, i need to set the original
value in the check box as soon as the user clicks on the edit button.

Thanks

Author
1 Mar 2005 2:53 AM
Elton Wang
Hi Houston,

I think you don't have to do this in edit event. You can
do it either in HTML code or in ItemDataBound event.

In HTML code:
<asp:CheckBox ID="ckID" Runat=server
Checked='<%# convert.tostring(DataBinder.eval
(Container.DataItem,"FieldName"))=="True" ? true : false) %
>'></asp:CheckBox>


Or in ItemDataBound event

ListItemType itemType = e.Item.ItemType;
if (itemType != ListItemType.Header && itemType !=
ListItemType.Pager && itemType != ListItemType.Footer &&
itemType != ListItemType.Seperator){

    DataRowView drv = (DataRowView)e.Item.DataItem;
    bool bData = (bool)drv[colIndex];
    CheckBox ckBox = (CheckBox)e.Item.FindControl("ckID");
    ckBox.Checked = bData;
}

HTH

Elton Wang
elton_w***@hotmail.com


>-----Original Message-----
>Hi all, i am having a problem with re-assigning the
original value in the
>checkbox when the datagrid is in edit mode. I have tried
finding the control
>using findcontrol method in the edit event but can't. I
try to find the
>control in the update event and i can do it. But, i need
to set the original
Show quoteHide quote
>value in the check box as soon as the user clicks on the
edit button.
>
>Thanks
>.
>