Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 243
  • Last Modified:

Delete Row from Grid

Hi,

Pls find the attached image.

I have 2 dropdowns (NewsSector, NewsSectorType). when i select values from these 2 dropdowns and click on Add button, it will add rows to grid.
For each row I have Delete icon(img button), when user click on this button i have to delete row from grid(not from database).
Pls note that on click of this delete button, data should not be deleted from db. only from the grid?

how to do this?

pls find the code below:

protected void RadGridNewsSectorType_ItemCommand(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName == "Delete")
            {
                //pls help me to write code here
            }
        }
grid.jpg
0
swathi111
Asked:
swathi111
  • 2
1 Solution
 
Obadiah ChristopherCommented:
Please show us the code you have used to bind the gridview.
0
 
swathi111Author Commented:
Hi,

Pls find the attached file for code which i used to bind the grid
code.txt
0
 
Obadiah ChristopherCommented:
Int index=((GridviewRow)sender).RowIndex
RadGridNewsSectorType.Rows.Delete(index);
0
 
armchangCommented:
hi swathi111,

This is what I'm using in my projects.

protected void RadGridNewsSectorType_ItemCommand(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName == "Delete")
            {
                int ID = Convert.ToInt32((string)e.CommandArgument);
                dtSectors.Rows[ID].Delete();
                grdDetails.DataSource = dtSectors;
                grdDetails.DataBind();
            }
        }

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now