468,248 Members | 1,459 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,248 developers. It's quick & easy.

Button event in DataList

I have a Button in a DataList Footer. I add the click event like this:

void Item_DataBound(Object sender, DataListItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Footer)
{
Button ctlSave = (Button)e.Item.FindControl("ctlSave");
ctlSave.Click += new EventHandler(ctlSave_Click);
}
}

It seems that the ctlSave_Click method is never called though. Am I doing
this right?
Nov 18 '05 #1
1 1585
Hi,

you'd need to wire this event in ItemCreated. I don't think the code ever
reaches Footer in ItemDataBound as footer isn't bindable item by default. In
ItemCreated Footer is always accessed (Footer item created), so that way it
should work.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"David W. Simmonds" <da***@simmonds.ca> wrote in message
news:PVuZb.580343$ts4.375490@pd7tw3no...
I have a Button in a DataList Footer. I add the click event like this:

void Item_DataBound(Object sender, DataListItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Footer)
{
Button ctlSave = (Button)e.Item.FindControl("ctlSave");
ctlSave.Click += new EventHandler(ctlSave_Click);
}
}

It seems that the ctlSave_Click method is never called though. Am I doing
this right?

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Chris Fink | last post: by
3 posts views Thread by moondaddy | last post: by
3 posts views Thread by Chris | last post: by
2 posts views Thread by Chris Fink | last post: by
reply views Thread by manu_srinivasa | last post: by
3 posts views Thread by Patrick Olurotimi Ige | last post: by
1 post views Thread by Pavan | last post: by
16 posts views Thread by Vikas Kumar | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.