Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DELETE MORE THAN ONE ROW OF DATAGRID

Reply
Thread Tools

DELETE MORE THAN ONE ROW OF DATAGRID

 
 
Charleees
Guest
Posts: n/a
 
      06-16-2006
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

 
Reply With Quote
 
 
 
 
pradeep10@gmail.com
Guest
Posts: n/a
 
      06-16-2006

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


 
Reply With Quote
 
 
 
 
Charleees
Guest
Posts: n/a
 
      06-16-2006

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

 
Reply With Quote
 
bmicks@gmail.com
Guest
Posts: n/a
 
      06-16-2006
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
}
}
}

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can one declare more than one signal on one line? Merciadri Luca VHDL 4 11-01-2010 02:00 PM
delete MyClass doing more than MyClass::operator delete()? tom C++ 5 07-14-2006 06:21 PM
Determine if more than one row returned CJM ASP General 11 07-12-2006 01:56 PM
Clicking cancel affects more than one row in edit mode John Dalberg ASP .Net 0 12-20-2005 08:15 AM
Footer data - more than one row (sumarizing) Miguel Ramirez ASP .Net Datagrid Control 2 05-21-2004 10:47 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57