Changing ImageURL of Image Button which is added in template column of datagrid

R

raghunath

hello,


I have a template column in my datagrid.
To the header of template colum, i have added imagebutton.
On click of the imagebutton , i want to change imageurl of image button.



thanks in advance,
Raghunath.
 
M

Michael Tkachev

You have to find this control (ImageButton) in the datagrid and then change
value of property in this control.
For this method don't use OnClick and OnCommand events for this buttton.

protected void myItemCommand(... e) // Event OnItemCommand for Datagrid
{
ImageButton ib = ((ImageButton)e.Item.Cells[0].Controls[1]);
ib.ImageUrl = "...";
}

that's all :)

Michael


----- Original Message -----
From: "raghunath" <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
Sent: Wednesday, April 28, 2004 11:03 AM
Subject: Changing ImageURL of Image Button which is added in template column
of datagrid
 
K

Kubuli John

How do you know to use Cells[0] and Controls[1]? Is this documented
somewhere? I have had lots of problems trying to get an indexed
reference to a specific control in a DataGrid, particularly in a
template column custom header with multiple controls in it.

Thanks,

John H.

Michael Tkachev said:
You have to find this control (ImageButton) in the datagrid and then change
value of property in this control.
For this method don't use OnClick and OnCommand events for this buttton.

protected void myItemCommand(... e) // Event OnItemCommand for Datagrid
{
ImageButton ib = ((ImageButton)e.Item.Cells[0].Controls[1]);
ib.ImageUrl = "...";
}

that's all :)

Michael


----- Original Message -----
From: "raghunath" <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridcontrol
Sent: Wednesday, April 28, 2004 11:03 AM
Subject: Changing ImageURL of Image Button which is added in template column
of datagrid

hello,


I have a template column in my datagrid.
To the header of template colum, i have added imagebutton.
On click of the imagebutton , i want to change imageurl of image button.



thanks in advance,
Raghunath.
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top