473,320 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

DELETE MORE THAN ONE ROW OF DATAGRID

Hi all,

I have a DataGrid With Template Columns..
In the First Column i have a Check Box...

Also i have a Button Outside the DataGrid..Just Above it..

What i want to do is ....

I have to remove the Rows(Records) that are Checked in the Grid...

There may be more than 1 ChecBox Checked..

How could i do this..

ITs URgent..

Please Help..

Thanks in Advance..
Sanju.C

Jun 16 '06 #1
3 1609

Hello Charlees

On the DataItemBound you have to create a CheckBox dynamically and u
have to find the the checkbox which is checked from ther u can delete
the rows

here is the coding for that
CheckBox ch =
(CheckBox)grid.Tables["tablename"].coloumns["coloumnname"].Cells(0).FindControl("CheckBoxname");
if(ch.Checked)
then write code for delete

Charleees wrote:
Hi all,

I have a DataGrid With Template Columns..
In the First Column i have a Check Box...

Also i have a Button Outside the DataGrid..Just Above it..

What i want to do is ....

I have to remove the Rows(Records) that are Checked in the Grid...

There may be more than 1 ChecBox Checked..

How could i do this..

ITs URgent..

Please Help..

Thanks in Advance..
Sanju.C


Jun 16 '06 #2

Hi ,

I have to determine the Checked Check Boxes and using it the
corresponding DataGrid Rows.. On Delete Buton Click...

But item bound will not be called on ButtonClick Outside the Grid..

Then how could i Determine the CheckBoxes Checked and corresponding
Row..

Please Reply..

Sanju.C

Jun 16 '06 #3
I've done this in the past:

Assuming that you're setting the DataKeyField when databinding, you can
use code similar to the following on the button's click event -

private void dgDelete_OnClick(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
foreach( DataGridItem item in dg.Items )
{
HtmlInputCheckBox chkBox =
(HtmlInputCheckBox) item.FindControl("checkboxCol");

//If it's selected then delete it
if ( chkBox != null && chkBox.Checked )
{
int objectID =(int)dg.DataKeys[(int)e.Item.ItemIndex];
//call delete code here for the given objectID
}
}
}

Jun 16 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ryan Liu | last post by:
Hi there, I got a NullReferenceException when delete last row in a datagrid. I had hard time to solve since it does not occur in my own code. I put a datagrid in my inherited user control,...
6
by: I am Sam | last post by:
I keep getting this error and I don't know why: The path is too long after being fully qualified. Make sure path is less than 260 characters. Description: An unhandled exception occurred...
7
by: DanB | last post by:
I want to asked the user if he is sure before deleting a row in a datagrid. I've created an event handler for the underlying table using the RowDeleting Event. If the user responds that he...
2
by: Lars Netzel | last post by:
Hi What events are there to do things in when I am on a row in a datagrid (bound from a dataset) and press Delete key... There's no Delete Event on the drig and I can't figure out if there are...
1
by: johnb41 | last post by:
I have a datagrid that successfully allows editing and updating (with dataadapter.update command). I want the user to be able to edit the "text" in the datagrid, but i DON'T want the user to be...
0
by: laurent | last post by:
Environment: VS NET 2003 Fr Framework: 1.1 OS: WinXP SP2 Fr Hello I have a problem to add with pop-up and to delete in a datagrid(ButtonColumn delete) on WebForms. code button HTML which...
5
by: Jeff User | last post by:
Hello ..NET 1.1, VS 2003, C# & asp.net I have tried to follow msdn instructions and samples but I can not get an event to fire for this button on the datagrid. There has to be something obvious...
5
by: rn5a | last post by:
The .NET 2.0 documentation states the following: When using a DataSet or DataTable in conjunction with a DataAdapter & a relational data source, use the Delete method of the DataRow to remove...
10
by: amiga500 | last post by:
Hello, I have one basic simple question. When I have multiple records in the datagrid as follows: Code Product 1 Product 2 Product 3 11111 A B C...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.