views:

171

answers:

2

Hi All,

I have a GridView which is databound to an XML Datasource. For one of the columns I'm using a TemplateField and within it's ItemTemplate I have a CheckBox. I need to programatically add an EventHandler to the CheckBox. I was wondering if anyone can tell me which EventHandler from the GridView to use to add a CheckedChanged EventHandler to the CheckBox?

I've tried RowCreated and DataBound and haven't been able to get the CheckBox to postback with the CheckChanged EventHandler.

void gridPartnerSelection_RowCreated(object sender, GridViewRowEventArgs e)
        {
            GridViewRow row = e.Row;

            if (row.RowType == DataControlRowType.DataRow)
            {
                CheckBox ckbSendEmail = row.Cells[2].FindControl("ckbSendEmail") as CheckBox;
                ckbSendEmail.CheckedChanged += new EventHandler(ckbSendEmail_CheckedChanged); 
            }
        }

Thank you.

A: 

Turns out I had to set the AutoPostBack property of the CheckBox to True :)

I'm willing to delete this question if it won't be helpful to anyone else.

Sean
A: 

thanks this peace of code resolved my issue .....