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

  • Home
  • SEARCH
  • 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 6845139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:27:50+00:00 2026-05-27T00:27:50+00:00

I have a SQL like this; select B.LoweredUserName from USER_BAYI A, aspnet_Users B, aspnet_Membership

  • 0

I have a SQL like this;

select B.LoweredUserName
  from USER_BAYI A, aspnet_Users B, aspnet_Membership C
  where B.UserId = C.UserId
  AND B.UserName = A.USERNAME

It’s getting all username in my membership database.

enter image description here

I want to user Gridview’s delete properties for delete this users from my membership database.

My delete commands in sqldatasource is;

DeleteCommand="DELETE FROM aspnet_Users
WHERE  LoweredUserName = @LoweredUserName" ondeleted="SqlDataSource1_Deleted"

protected void SqlDataSource1_Deleted(object sender, SqlDataSourceStatusEventArgs e)
    {
        DbCommand cmd = e.Command;
        string username = cmd.Parameters["@LoweredUserName"].Value.ToString();
        Membership.DeleteUser(username);
    }

But this doesn’t even compile. Where am I doing wrong? Or can you show me a way for doing this?

  • 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-27T00:27:50+00:00Added an answer on May 27, 2026 at 12:27 am

    Set the DataKeyNames on the GridView like this: DataKeyNames="ProviderUserKey" and set the OnDeleteCommand to some method likie this: OnDeleteCommand="gvUser_DeleteCommand".

    Then in the code behind implement the onDelete method like this:

    protected void rgUser_DeleteCommand(object source, GridCommandEventArgs e)
    {
        GridDataItem gdiItem = (GridDataItem)e.Item;
        try
        {
            string strUserKey = gdiItem.GetDataKeyValue("ProviderUserKey").ToString();
            Guid guiUserKey = new Guid(strUserKey);
            string strUserName = Membership.GetUser(guiUserKey).UserName.ToString();
    
            Membership.DeleteUser(strUserName);
        }
        catch (Exception ex)
        {
            //handle exception
        }
    }
    

    Just for more info, you are binding to the wrong event on the SqlDataSource. The OnDeleted event is fired after the record is deleted, and you need the OnDeleting event because it is fired before the record is deleted. In the OnDeleting event you can add your custom delete code and then cancel the event, but you can’t do theat in the OnDeleted event.

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

Sidebar

Related Questions

i have sql statement like this SELECT DISTINCT results_sp_08.material_number FROM results_sp_08 INNER JOIN courses
I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0;
If i have a parameterized SQL statement like this: SELECT * FROM table WHERE
Right now, I have a SQL Query like this one: SELECT X, Y FROM
I have a lot of SQL queries like this: SELECT o.Id, o.attrib1, o.attrib2 FROM
I have a SQL query like this: SELECT * FROM ( (SELECT name FROM
I have a sql like this: SELECT *, count(*) as cc FROM manytomany GROUP
I have a sql like this: SELECT * FROM tableA WHERE column_a = sth
I have a sql query that looks like this: SELECT SUM(A) AS expr1 FROM
I have a SQL query, looks something like this: select name, count (*) from

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.