datagrid imagebutton

M

mike parr

In a datagrid is it possible to use an imagebutton in for my
ButtonColumn rather than the standard button provided? And if so, does
anybody have a code example?


Cheers,

Mike
 
A

Ashish M Bhonkiya

A TemplateColumn is used in cases where authors need complete control over
the contents of a Datagrid column. The TemplateColumn is declared with an
<ItemTemplate> element, which in turn is used to define the content that
will be rendered for each item in the column. The ItemTemplate can include
any valid HTML, including s.

To add a template column

1.. Set the DataGrid control's AutoGenerateColumns property to false.
<asp:datagrid id="myGrid" runat="server"
autogeneratecolumns=false
...
2.. Within the DataGrid declaration, declare a <Columns> element.
3.. Within the Columns element, define the <asp:TemplateColumn> control,
along with the required <ItemTemplate> element.
4.. Within the ItemTemplate, define the HTML or server control you intend
to display.
5.. Optionally set the TemplateColumn control's other properties
<columns>

<asp:templatecolumn>

<itemtemplate>

<img width=60 align="top"
src="/aspxtreme/shared/images/title-{0}.gif">
</itemtemplate>
</asp:templatecolumn>

...

</columns>HTH
Regards
Ashish M Bhonkiya
 
M

mike parr

Ashish,

When using a Button Column, I would normally use CommandName to set the
name of an event to react to the button being pressed.

How would I do this using a Template Column?


Thanks,

Mike
 
A

Ashish M Bhonkiya

mike parr,

do it in the DataGrid1_ItemCommand of the datagrid

Regards
Ashish M Bhonkiya
 

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,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top