Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Deletion items on a grid

Posted on 2006-05-16
4
Medium Priority
?
215 Views
Last Modified: 2010-04-16
Hi experts,

I am trying to delete items on my grid

it is initialised
here

private void InitializeComponent()
            {    
                  this.cmdNew.Click += new System.EventHandler(this.cmdNew_Click);
                  this.cmdSearch.Click += new System.EventHandler(this.cmdSearch_Click);
                  this.dgUsers.ItemCreated += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dgUsers_ItemCreated);
                  this.dgUsers.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgUsers_DeleteCommand);
                  this.dgUsers.SelectedIndexChanged += new System.EventHandler(this.dgUsers_SelectedIndexChanged);
                  this.Load += new System.EventHandler(this.Page_Load);
            this.dgUsers.PageIndexChanged+=new DataGridPageChangedEventHandler(this.dgUsers_PageIndexChanged);
           

            }

his is the code

      private void dgUsers_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
            {
                  db.deleteUser(e.Item.Cells[2].Text);
            bindUserGrid();
            }

thanks
0
Comment
Question by:SirReadAlot
  • 3
4 Comments
 
LVL 10

Accepted Solution

by:
Ready1 earned 2000 total points
ID: 16690583
what is db?

have you accept the changes after you bind the user grid again?

eg. if you have a dataset called userDS, after you delete a row, you would then call userDS.AcceptChanges() and then bind the dataset to a datagrid.

REgards,
Ready1
0
 

Author Comment

by:SirReadAlot
ID: 16690619
db is a class
0
 

Author Comment

by:SirReadAlot
ID: 16690818
hi guys.

I have tried this
private void dgUsers_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
            {
      
                  db.deleteUser(e.Item.Cells[2].Text);
                  bindUserGrid();
            }

            private void dgUsers_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
            {
                  if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                  {                        
                        Button btnDelete = (Button)e.Item.Cells[1].Controls[0];                        
                        btnDelete.Attributes.Add("onclick", "return confirm_delete();");

                  }
            }

but no deletion occurs
0
 

Author Comment

by:SirReadAlot
ID: 16691103
i have stuck a break point there, but doesn't hit it
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question