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 1102943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:15:52+00:00 2026-05-17T01:15:52+00:00

I have a repeater which binds a set of data. Within this repeater is

  • 0

I have a repeater which binds a set of data. Within this repeater is a column with various controls for updating, deleting, etc. These are image buttons which fire an onclick event such as “DeleteRecord”. All this does is fire a stored procedure, passing in the ID of the record to delete from the CommandArgument of the object.

This works wonderfully… except for one rather huge problem. Once you delete a record, if you refresh the page, the record where the first deleted record used to be gets deleted.

For instance… if I have 4 records

1 Record1
2 Record2
3 Record3
4 Record4

and I delete record 2… The page reloads with (which is fine):

1 Record1
3 Record3
4 Record4

…if I then hit refresh…

1 Record1
4 Record4

I assume this is because the erroneously deleted object (record3) is now in the same hierarchical place as the old object used to be and .net therefore doesn’t know the difference, the page refreshes and fires the onlick event, grabbing out the command argument of the new object and deletes based on the ID as obtained from the commandargument of the new object.

This is obviously a huge problem, if a client did this it would destroy data erroneously and I’m at a loss here.

Is there any way to stop this from happening? I’m not sure if there is a better way to go about doing things or not. If there isn’t, I need some sort of way to tell the page not to execute the event or to cross reference the ID of the object that is intended for deletion against the object itself…

Code below for convenience…

EDIT Wrapped a LinkButton around it because I have some jquery code in here as well which stops the page execution to wait for user confirmation. Pressing “ok” continues page execution.

<asp:LinkButton ID="oDeleteLink" CssClass="oDeleteIcon" CommandName="Delete" CommandArgument='<%# Eval("iAccountID") %>' runat="server">
     <asp:ImageButton ImageUrl="/files/system/icons/trash-steel-16.png" ToolTip="Delete This Account" AlternateText="Delete" ID="oDeleteIcon" runat="server" />
</asp:LinkButton>

    protected void oAccounts_ItemCommand(Object Sender, RepeaterCommandEventArgs e) {
        if (e.CommandName == "Delete") {
            int ID = e.CommandArgument.ToString().Numeric();
            db.SPs.SpDeleteAccount(ID).Execute();
            UI.Confirm(uiBroadcast, "Account has been deleted", "300px");
            BindAccounts();
        }
    }

Would appreciate any feedback you folks could give.

  • 1 1 Answer
  • 1 View
  • 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-05-17T01:15:52+00:00Added an answer on May 17, 2026 at 1:15 am

    Use ItemCommand event and CommandName/CommandArgument instead:

    <!-- CommandArgument binding would be the same as whatever you are binding your ID label text value to -->
    <asp:ImageButton 
        CommandName="Delete" CommandArgument='<%# Eval("ID") %>'
        ImageUrl="/files/system/icons/trash-steel-16.png"  
        ToolTip="Delete This Account" 
        AlternateText="Delete" CssClass="oDeleteIcon"  
        ID="oDeleteIcon" runat="server" /> 
    

    And the event handler:

    void Repeater_ItemCommand(Object Sender, RepeaterCommandEventArgs e) {        
        if( e.CommandName == "Delete" ) {
            int id = e.CommandArgument.ToString().Numeric();
    
            db.SPs.SpDeleteAccount(id).Execute();
            // the rest of your code
        }
    } 
    

    This way the delete button itself is indicating what ID to delete, as opposed to relying on positional elements in your repeater.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some data which I am binding to a dropdown dynamically like this:
Say I have this repeater which makes use of a public function called Test
I have an asp.net repeater which binds the memberid to the id of the
Hi have a repeater which is inside a gridview. when i bind the data
I have a repeater which displays and data bind the source of tab links.
I have an ASP:Repeater Which I would like to display a list of check
I have a repeater, which is dynamically created on tab index change of AJAX
I have an UpdatePanel which has a Repeater inside it, and inside of the
I have a view in which I there is a repeater control wrapped with
I have a ticker which uses a jquery and a Repeater.But I only get

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.