disabling delete buttons in datagrid

S

Sharon McCarty

Hi everyone , I have a datagrid containing some controls.

The columns are as follows:

---------------------------------------------------
ID |Name |Description |Edit |Delete |
---------------------------------------------------


The Edit and Delete are column buttons. I would like to disable the
delete button as soon as someone clicks on the Edit button (for a
particular row). In the code, I have:

private void somedatagrid_EditCommand(object source,
DataGridCommandEventArgs e)
{
Button b = new Button();
b= (Button)e.Item.Cells[4].FindControl("What is the name of the
control");
b.Enabled = false;
return;
}

I saw this code snippet in the discussion groups, but I would like to
know what I would put in as a parameter for FindControl(). I know
it's supposed to be the id of the control, but I can't seem to find
the id of the delete push button... Can someone tell me where I would
find the id name of the delete button, so I can feed it into the
FindControl parameter?

I've also tried doing: b = (Button)e.Item.Cells[4].Controls[0];

But I keep getting an index out of bounds... :(

Thanks

Sharon.
 
R

ricolee99

Sharon said:
Hi everyone , I have a datagrid containing some controls.

The columns are as follows:

---------------------------------------------------
ID |Name |Description |Edit |Delete |
---------------------------------------------------


The Edit and Delete are column buttons. I would like to disable the
delete button as soon as someone clicks on the Edit button (for a
particular row). In the code, I have:

private void somedatagrid_EditCommand(object source,
DataGridCommandEventArgs e)
{
Button b = new Button();
b= (Button)e.Item.Cells[4].FindControl("What is the name of the
control");
b.Enabled = false;
return;
}

I saw this code snippet in the discussion groups, but I would like to
know what I would put in as a parameter for FindControl(). I know
it's supposed to be the id of the control, but I can't seem to find
the id of the delete push button... Can someone tell me where I would
find the id name of the delete button, so I can feed it into the
FindControl parameter?

I've also tried doing: b = (Button)e.Item.Cells[4].Controls[0];

But I keep getting an index out of bounds... :(

Thanks

Sharon.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top