0
votes

Given the following page (latest update).

 <%@ Page Title="" Language="C#" MasterPageFile="~/master/superuser.master" AutoEventWireup="true" CodeFile="default.aspx.cs" Inherits="permissions_default" %>

 <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server"></asp:Content>
 <asp:Content ID="Content2" ContentPlaceHolderID="PageContent" runat="Server">
  <h1>Permissions Management</h1>
<div class="row">
      <div class="span9">
        <form runat="server">
            <fieldset>
                <legend>CRM User Permissions</legend>
                <asp:Repeater ID="rptUserPermissions" runat="server" OnItemCommand="rptUserPermissions_ItemCommand">
                    <HeaderTemplate>
                        <table class="table table-striped autowidth">
                            <thead>
                                <tr>
                                    <th>User</th>
                                    <th>Program</th>
                                    <th>Action</th>
                                </tr>
                            </thead>
                            <tbody>
                    </HeaderTemplate>

                    <ItemTemplate>
                        <tr>
                            <td><%# DataBinder.Eval(Container, "DataItem.user_name") %></td>
                            <td><%# DataBinder.Eval(Container, "DataItem.program_name") %></td>
                            <td>
                                <asp:Button ID="btnDelete" Text="Delete" runat="server" CommandName="cmd_Delete" CommandArgument="<%# DataBinder.Eval(Container, "DataItem.id") %>" />
                            </td>
                        </tr>
                    </ItemTemplate>

                    <FooterTemplate>
                        <tr>
                            <td>
                                <asp:DropDownList ID="ddUser" runat="server" />
                            </td>
                            <td>
                                <asp:DropDownList ID="ddProgram" runat="server" />
                            </td>
                            <td>
                                <asp:Button ID="btnSubmit" Text="Add New" runat="server" CommandName="cmd_Submit"/>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    </FooterTemplate>
                </asp:Repeater>
            </fieldset>
        </form>
    </div>
    <div class="span1">&nbsp;</div>
    <div class="span4"></div>
  </div>
</asp:Content>
 <asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="Server">
</asp:Content>

How can I handle the button onclick events for btnSubmit and btnDelete in the repeater footer without throwing an invalid postback or callback exception?

UPDATE: Inputting the databinder.evals on the delete btn with command argument now throws out a parse erorr message that reads as follows:

Parser Error Message: The server tag is not well formed.
1

1 Answers

1
votes

You actually want to use the itemcommand event that gets triggered from a button push in the item template. that passes in the context of the row that you can work with from there.

You can see an example here:

http://nazimakul.com/article/repeater-itemcommand-event-in-asp-net_1049