views:

84

answers:

1

asp:Button inside SharePoint Dataview Rows with onclick event does not call C# function. Pull it out of Dataview and works fine.

I have a ASP.NET Button I've placed inside a SharePoint DataView's rows with an onclick event pointing to C# function block inside my page. The page refreshes when I click on them, but it's not hitting that code block. If I move the button to outside the dataview and make the ID fixed, the code works beautifully. what's up with that?

the button in the Dataview:

<asp:Button runat="server" Text="Delete" id="Delete{@ID}" CommandArgument="{@FileRef}" OnClick="DeleteDoc"/>

my C# onclick handler (inline C# on the page)

void DeleteDoc(object sender, EventArgs e){sendmail("DeleteDoc");Button b = sender as button;.. more code

This is all inline code and I'm working from SharePoint Designer. Not sure how I can troubleshoot this.

Am I missing something here, maybe I need to add an Itemtemplate or something like we need to in a ASP.NET gridview controls?

Thanks.

+1  A: 

IIRc, you need to use Actions, not events.

leppie
Thanks. I'm having trouble finding any good examples on how to do this. Will I be able to call a inline C# function from these actions? If not, i might as well redirect to a page that will delete the row and come back.
cyberpine
I'm playing with the DataView Add, Edit Delete buttons to see how dynamic we can make them.
cyberpine