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

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...
 
G

Guest

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
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top