0

I have a repeater in my webpage which containing Buttons as well..

        <asp:Repeater ID="rptView" runat="server" OnItemDataBound="rptView_ItemDataBound">
            <HeaderTemplate>
                <table border="0" width="90%">
                    <tr class="RepeaterHeader">
                        <th align="center">Date</th>
                        <th align="center">Category</th>
                        <th align="center">Description</th>
                        <th align="center">Amount</th>
                        <th align="center"></th>
                    </tr>
            </HeaderTemplate>
            <ItemTemplate>
                <tr class="RepeaterData">
                    <td align="center"><%#Eval("CurrentDate") %></td>
                    <td align="center"><%#Eval("Category") %></td>
                    <td align="center"><%#Eval("Description") %></td>
                    <td align="center"><%#Eval("Amount", "{0:C}")%></td>
                    <td align="center"><asp:Button ID="btnDelete" runat="server" Text="Delete" CssClass="Button" OnClick="Remove" /></td>
                </tr>
            </ItemTemplate>

i want detect which row of the Button is exaclty clicked,
then i have to retrieve the value of Category of the Button clicked row due to remove the data.
Any way is able to retrieve data of the repeater from code behind?

3
Contributors
9
Replies
18
Views
3 Years
Discussion Span
Last Post by |-|x
0

Cannot Use CommandName and OnCommand Property due to

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 

Parser Error Message: Server tags cannot contain <% ... %> constructs.
0
 <asp:Button ID="btnDelete" runat="server" Text="Delete" CssClass="Button" OnComand="Remove" CommandName=<%#Eval("Category") %> />

The Parser Error is Encountered.
But i still have no idea how to retrieve multiple value and how about code behind if using CommandName=<%#Eval("Category")%>?

0

I am trying to display the Category data and the error i got.

Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

Code Behind

protected void Remove(object sender, CommandEventArgs e)
{
    Response.Write(e.CommandName.ToString());           
}
0

A gridview also okay. As long as able to remove particular data from database :)

0

I realise you have probably already moved on from this, but for posterity sake...

CommandName=<%#Eval("Category")%>

you need quotes when specifying server values, which is probably the cause of the parsing error.

CommandName='<%#Eval("Category")%>'
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.