How can I add an event to a control in a templete column?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a templete column, and a DropDownList in header templete. I want to
add a SelectedIndexChanged event to that DropDownList. But I couldn't. How
can I do that?

Thanks...
 
In your HTML for datagrid template, write ... <asp:DropDownList
OnSelectedIndexChanged="MyEvent"></asp:DropDownList>

In you code behind:

public void MyEvent(object source, System.EventArgs e)
{
// Handle your event here...
}

This technique is called event bubbling. Making the event handler's scope as
public is very important
 
Back
Top