Solved

Delete Row from Grid

Posted on 2013-01-05
4
230 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

910 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

22 Experts available now in Live!

Get 1:1 Help Now