Problem editing checkbox template column

  • Thread starter Houston Lucifer
  • Start date
H

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
 
E

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
(e-mail address removed)
 

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,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top