开发者

SharePoint - Passing Dataview Row Arguments to a C# function from ASP.net button

开发者 https://www.devze.com 2023-01-15 23:01 出处:网络
I\'ve done this with a asp.net Gridview. but does anybody have any examples on how to pass row information from an asp.net button inSharePoint Dataview开发者_如何学C rows to an inline C# function?

I've done this with a asp.net Gridview. but does anybody have any examples on how to pass row information from an asp.net button in SharePoint Dataview开发者_如何学C rows to an inline C# function?

the button Repeats as follows:

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

My function looks like this:

void DeleteDoc(object sender, EventArgs e) { }

}

I tried adding another parameter but get:

No overload for 'DeleteDoc' matches delegate 'System.EventHandler'


Try to change your method access modifier to protected and OnClick="DeleteDoc()" to OnClick="DeleteDoc".

Also i didn't managed to make it work with id="Delete{@ID}" so try without that to.

This worked on my test case

 <asp:Button runat="server" Text="Delete"  
             OnClick="DeleteDoc" 
             CommandArgument='<%# Eval("ID")%>'/>

and

   protected void DeleteDoc(object sender, EventArgs e)
        {
            Button b = sender as Button;            
            YourDeleteDocumentHelperMethod(b.CommandArgument);
        }
0

精彩评论

暂无评论...
验证码 换一张
取 消