Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Cappy #1
Accessing data object on delete command.
Hi guys.
I have a datagrind that is bound to a custom collection of a custom
object.
When a delete button is pressed in the datagrid, I not only want to
remove the row from the grid, I want to delete the object from the
collection that is bound to the grid.
So far I have this.
public void groupsGrid_DeleteCommand(object sender,
DataGridCommandEventArgs e)
{
try
{
//My Group object UMGroup grouptodelete =
(UMGroup)e.Item.DataItem;
// attempt delete
groupsCollection.Remove(grouptodelete);
}
catch(Exception exp)
{
Errortxt.Text = exp.Message;
}
//Disable Edit mode
groupsGrid.EditItemIndex = -1;
//Refresh data in grid
PopulateDatagrid();
}
My problem is, grouptodelete comesback with object undefined. Is there
away of getting access to the object that is supplying data to the row
that fired the delete command?
Thanks
Amit
Cappy Guest
-
how to delete some of the history data in chatcomponent shared object
Hi, i have made a chat application using chat component, but the chat component store the data permanentely in the server, How to delete the... -
Delete form - Post data to a table and delete uponsubmit.
I have a delete form that I'd like to post the data to a table (delete_pcn) and delete upon submit, so that all deletions may be kept track of in... -
ASP/VBS Using Command to Insert/Update/Delete
Hi, I would just like to know when/why etc would you command and if there any penalties in using the command. Thanks, Sanjay -
Accessing DataRow Items by Name in Edit/Update/Delete Event
Hi there. I have a small problem with DataGrid in ASP.NET & C#. In the ItemDataBound Event I can use the following code DataRowView drvSE =... -
unix command to delete parts of a file
hello all! I'd like to ask if there's a unix command that could delete parts of the file given a string. Example: Given: File1 which contains... -
Elton W #2
Accessing data object on delete command.
Hi Cappy,
In order to delete the object, you should get it first.
Suppose you have a key for the custom object. You can get
the key in couple of ways:
string key = datagrid.DataKeys[e.Item.ItemIndex];
string key = e.Item.Cells[key_Column_Index].Text; // for
BoundColumn
string key = ((contrl_type)e.Item.FindControl
("key_Column_ID")).Text; // for TemplateColumn
Then you can get your custom object by the key:
UMGroup grouptodelete = method_of_find_object(key);
// then delete the object
if (grouptodelete != null)
{
groupsCollection.Remove(grouptodelete);
}
HTH
Elton Wang
[email]elton_wang@hotmail.com[/email]
of a custom>-----Original Message-----
>Hi guys.
>
>I have a datagrind that is bound to a custom collectiononly want to>object.
>
>When a delete button is pressed in the datagrid, I notfrom the>remove the row from the grid, I want to delete the objectUMGroup>collection that is bound to the grid.
>
>So far I have this.
>
>public void groupsGrid_DeleteCommand(object sender,
>DataGridCommandEventArgs e)
> {
>
>
> try
> {
> //My Group object
grouptodelete =(grouptodelete);>(UMGroup)e.Item.DataItem;
>
> // attempt delete
> groupsCollection.Removeexp.Message;>
> }
>
> catch(Exception exp)
> {
> Errortxt.Text =undefined. Is there> }
>
> //Disable Edit mode
> groupsGrid.EditItemIndex = -1;
>
> //Refresh data in grid
> PopulateDatagrid();
> }
>
>My problem is, grouptodelete comesback with objectdata to the row>away of getting access to the object that is supplying>that fired the delete command?
>
>Thanks
>Amit
>.
>Elton W Guest



Reply With Quote

