DataGrid Cell with Image Button In It

K

KJ

I create a datagrid and at runtime I add an ImageButton to certain
cells(e.Item.Cells.Controls.Add(imgbutton)). Now when I click on a row
that contain an image button, in the ItemCommand event the row is
return.

So I do e.Item.Cells(3) is the cell with the control in it supposely.
When I do e.Item.Cells.Controls.Count it returns 0. Why? How can I
tell if I clicked on a row with an imagebutton in cell 3?

Thanks
 
M

Micharel Tkachev

Yes, you have to use CommandName or Command Argument.
Eg.

C#

ImageButton btn = new ImageButton();
btn.CommandName = "xx";

protected void myItemCommand(...)
{
if(e.CommandName == "xx")
{
// your code
}
}
 
K

KJ

That works if you are clicking on the image in the row but I actually
have 2 imagebutton in the row. One I click on and another that I add
if a certain condition is met. I can tell which row is clicked but I
need to find out if the other imagebutton is contained in the row.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top