Solved

Delete Row from Grid

Posted on 2013-01-05
4
228 Views
Last Modified: 2013-01-06
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
Comment
Question by:swathi111
  • 2
4 Comments
 
LVL 20

Expert Comment

by:informaniac
ID: 38746424
Please show us the code you have used to bind the gridview.
0
 

Author Comment

by:swathi111
ID: 38746503
Hi,

Pls find the attached file for code which i used to bind the grid
code.txt
0
 
LVL 20

Expert Comment

by:informaniac
ID: 38746529
Int index=((GridviewRow)sender).RowIndex
RadGridNewsSectorType.Rows.Delete(index);
0
 
LVL 7

Accepted Solution

by:
armchang earned 500 total points
ID: 38746546
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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

757 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now