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:
td class="ms-vb" style="width: 70px"><asp:Button runat="server" Text="Delete" id="Delete{@ID}" CommandArgument="{@FileRef}" OnClick="DeleteDoc"/> </td>
my C# onclick handler (inline C# on the page)
void DeleteDoc(object sender, EventArgs e)
{
Button b = sender as Button;
.. more code
The buttons are rendered and they look like this:
input type="submit" name="ctl00$PlaceHolderMain$g_08acadfd_957b_4112_a426_cc7c81991c1e$Delete1" value="Delete" id="ctl00_PlaceHolderMain_g_08acadfd_957b_4112_a426_cc7c81991c1e_Delete1"
Thie code block in inline 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 the ASP.N
View Complete Post