Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7958479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:25:45+00:00 2026-06-04T04:25:45+00:00

I have a nested repeater with a delete button in it. This button deletes

  • 0

I have a nested repeater with a delete button in it. This button deletes a student from a group. but when I press the delete button it just goes through the nested repeater again and I get:

Invalid postback or callback argument.

Stack Trace:

[ArgumentException: 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.]
System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument) +9714590
System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) +111
System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +29
  System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724

my asp.net file:

<!-- Begin modal -->
<asp:Repeater ID="RepeaterModal" OnItemDataBound="RepeaterModal_ItemDataBound" runat="server">
    <HeaderTemplate>
    <div id="modal">
    </HeaderTemplate>
    <ItemTemplate> 
        <div id="dialog<asp:Literal ID='ltlModalNumber' runat='server' />" class="window">
            <div class="contents">
                <h3>Students in group <asp:Literal ID="ltlModalGroup" runat="server" /></h3>
                <ul>
                <asp:Repeater ID="repeaterModalStudentList" Runat="server">
                    <ItemTemplate>
                        <li class="modalStudent"><%# Eval("Name") %></li>
                        <li class="modalStudentClassDelete">
                            <asp:ImageButton ID="imgDeleteStudent" runat="server" ImageUrl="styles/img/icons/2.png" CommandName="deleteStudent" OnClick="btnDeleteStudent_Click" ToolTip="Delete this student" />
                        </li>
                    </ItemTemplate>
                </asp:Repeater>
                </ul>                       

                <a href="#" class="close">Close</a>
            </div>
        </div>
    </ItemTemplate> 
    <FooterTemplate>
    </div>
    </FooterTemplate>

</asp:Repeater>
<!-- End modal -->

In my code behind file I do:

//A field 
int r = 0;

//Populates the table with the list of groups.
RepeaterModal.DataSource = listOfGroups;
RepeaterModal.DataBind();

listOfGroups contains a list with Group objects that contain a group_Id, name, code, Students object with strings for the name of the students.

//Repeater methode to put the values in the correct labels of the modal window
public void RepeaterModal_ItemDataBound(Object Sender, RepeaterItemEventArgs e) {
    //Execute the following logic for Items and Alternating Items.
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {
        ((Literal)e.Item.FindControl("ltlModalNumber")).Text = ((Groups)e.Item.DataItem).Group_Id.ToString();
        ((Literal)e.Item.FindControl("ltlModalGroup")).Text = ((Groups)e.Item.DataItem).Code.ToString();    

        //Fill the repeater inside the repeater with the students name
        Repeater repeaterModalStudentList = ((Repeater)e.Item.FindControl("repeaterModalStudentList"));
        repeaterModalStudentList.DataSource = ((Groups)e.Item.DataItem).Students;
        repeaterModalStudentList.DataBind();

        ImageButton imgDeleteStudent = repeaterModalStudentList.Items[0].FindControl("imgDeleteStudent") as ImageButton;

        if (imgDeleteStudent != null) {
                imgDeleteStudent.CommandArgument = ((Groups)e.Item.DataItem).Students[r].Student_Id.ToString();
                r++;
        }
    }
}

protected void btnDeleteStudent_Click(object sender, EventArgs e) {     
    ImageButton b = (ImageButton)sender;
    string value = b.CommandArgument;

    Students student = new Students();
    student.DeleteStudent(int.Parse(value));

    Response.Redirect(Request.RawUrl);
}

What am I missing or doing wrong that I keep getting that error? adding EnableEventValidation is not the solution. It’s something with the commandArgument.

Edit

Lol, Added if(!IsPostBack), ain’t getting the error anymore. But there isn’t a value in the CommandArgument.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:25:45+00:00Added an answer on June 4, 2026 at 4:25 am

    You are assigning the CommandArgument, but your method is btnDeleteStudent_Click

    Update:

    //Repeater methode to put the values in the correct labels of the modal window 
    public void RepeaterModal_ItemDataBound(Object Sender, RepeaterItemEventArgs e) { 
        //Execute the following logic for Items and Alternating Items. 
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { 
            ((Literal)e.Item.FindControl("ltlModalNumber")).Text = ((Groups)e.Item.DataItem).Group_Id.ToString(); 
            ((Literal)e.Item.FindControl("ltlModalGroup")).Text = ((Groups)e.Item.DataItem).Code.ToString();     
    
            //Fill the repeater inside the repeater with the students name 
            Repeater repeaterModalStudentList = ((Repeater)e.Item.FindControl("repeaterModalStudentList")); 
            repeaterModalStudentList.DataSource = ((Groups)e.Item.DataItem).Students; 
            repeaterModalStudentList.DataBind(); 
            repeaterModalStudentList.ItemDataBound += repeaterModalStudentList_ItemDataBound; 
        } 
    } 
    
    //Repeater methode to put the values in the correct labels of the modal window 
    public void repeaterModalStudentList_ItemDataBound(Object Sender, RepeaterItemEventArgs e) { 
        //Execute the following logic for Items and Alternating Items. 
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {       
    
            ImageButton imgDeleteStudent = repeaterModalStudentList.Items[0].FindControl("imgDeleteStudent") as ImageButton; 
    
            if (imgDeleteStudent != null) { 
                imgDeleteStudent.CommandArgument = ((Student)e.Item.DataItem).Student_Id.ToString(); 
            } 
        } 
    } 
    
    
    protected void btnDeleteStudent_Click(object sender, EventArgs e) {  
        ImageButton btn = (ImageButton)sender; 
        int studentId = (int)btn.CommandArgument; 
    
        Students student = new Students(); 
        student.DeleteStudent(studentId); 
    
        Response.Redirect(Request.RawUrl); 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a nested repeater set up but the child repeater control is not
I have nested repeaters like this: <asp:Repeater ID=rptQuestoes runat=server> <HeaderTemplate> <ol class=orderedList> </HeaderTemplate> <ItemTemplate>
I have a user control nested in a repeater. Inside my user control I
Is it possible to have nested set capabilities in this somewhat custom setup? Consider
I'm working on a navigation control. I have nested lists which creates this: What
I have two nested loop in XSL like this, at this moment I use
I have a nested list like this: <ul class=list> <li class=list_item_type_1> <ul class=list> <li
I have a nested Repeater control in the ItemTemplate of another Repeater. I want
I have a nested repeater control. Here is what the HTML looks like: <ItemTemplate>
I followed this simple tutorial and created a nested repeater. This tutorial is simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.