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
  • 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-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 found this example on StackOverflow: var people = new List<Person> { new
I have a login.jsp page which contains a login form. Once logged in the
i have a input tag which is non editable, but some times i need
I have a project that adds elements to an AutoCad drawing. I noticed that
I have a script that appends some rows to a table. One of the
I have a new web app that is packaged as a WAR as part
I have several USB mass storage flash drives connected to a Ubuntu Linux computer
I have a snippet to create a 'Like' button for our news site: <iframe
Let say I have the following desire, to simplify the IConvertible's to allow me
I want to have generalised email templates. Currently I have multiple email templates with

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.