473,383 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Datagrid Button Column with ImageButton

I have a button column in a datagrid that is the delete button. Right
now it is just a text link. When I go into the Property Builder My
button choices are only LinkButton or PushButton. I'd like it to be an
ImageButton so I tried converting the column to a Template Column.

Then I edited the template to change the LinkButton to an ImageButton
and replaced the text property with ans ImageURL property.

The Datagrid looks how I wanted it with the graphic in place, but the
delete command no longer seems to fire when I click on it.

So I changed this working code:
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton runat="server" Text="Delete" CommandName="Delete"
CausesValidation="false"></asp:LinkButton>
</ItemTemplate> </asp:TemplateColumn>

To this:

<asp:TemplateColumn>
<ItemTemplate>
<asp:ImageButton runat="server" ImageURL="images/test.gif"
CommandName="Delete" CausesValidation="false"></asp:ImageButton>
</ItemTemplate> </asp:TemplateColumn>

And now I can see it causes a postback but the Delete Command does not
fire. What am I missing? Thanks!

Matt
Nov 19 '05 #1
1 3390
Hi Matt,

When you use Template Column + ImageButton (or other button), you should
process data in DataGrid_ItemCommand event.

if (e.CommandName.Equals("Delete")){
// process
}

HTH

Elton Wang
el********@hotmail.com

"MattB" wrote:
I have a button column in a datagrid that is the delete button. Right
now it is just a text link. When I go into the Property Builder My
button choices are only LinkButton or PushButton. I'd like it to be an
ImageButton so I tried converting the column to a Template Column.

Then I edited the template to change the LinkButton to an ImageButton
and replaced the text property with ans ImageURL property.

The Datagrid looks how I wanted it with the graphic in place, but the
delete command no longer seems to fire when I click on it.

So I changed this working code:
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton runat="server" Text="Delete" CommandName="Delete"
CausesValidation="false"></asp:LinkButton>
</ItemTemplate> </asp:TemplateColumn>

To this:

<asp:TemplateColumn>
<ItemTemplate>
<asp:ImageButton runat="server" ImageURL="images/test.gif"
CommandName="Delete" CausesValidation="false"></asp:ImageButton>
</ItemTemplate> </asp:TemplateColumn>

And now I can see it causes a postback but the Delete Command does not
fire. What am I missing? Thanks!

Matt

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jon | last post by:
Can you add client side controls inside a asp .net datagrid? The code below shows what I have template column inside a asp .net datagrid... <Columns> <asp:TemplateColumn HeaderText="Exist Or...
2
by: Clayton Hamilton | last post by:
I have a DataGrid on a webform bound to a Datasource and can successfully use <ItemTemplate> to create edit/update/cancel functionality for user maintenance of data. I use separate logic to delete...
1
by: Javier Ros | last post by:
hi guys, I´m working with datagrids and use the button columns, but I don´t like the buttons prefers the imagebutton, how to put a image in the place of button? without change the HTML code,...
2
by: Patrick Delifer | last post by:
Hi, I am trying to implement a JS confirm dialog when a user is deleting something off my Datagrid. The problem is that I don't have a Delete button in which case I could write the following...
0
by: Linus | last post by:
Hi, I have a datagrid nested inside another datagrid, the edit/update/cancel command works fine on the outter datagrid but I'm having problems with the inner one. There are 2 problems and here's...
4
by: rkbnair | last post by:
Is there any way to display an image button instead of the traditional Edit/Update/Cancel push button in a datagrid (with bound data)?
2
by: Lars Netzel | last post by:
Hi I had a Delete Column in a datagrid that was a Linkbutton. That needed to change into a ImageButton because of the design demands in the project. Then how do I trigger the DeleteCommand with...
2
by: MrMike | last post by:
Hi. I have an asp:ImageButton which appears when a datagrid row is placed in Edit mode. The button has it's own click event which fires when the button is clicked. Within the button's click...
3
by: Terry Olsen | last post by:
I have a DataGrid with a Template Column. In the ItemTemplate I have an ImageButton. I want to have the user select a row by clicking on the ImageButton. When the user clicks an ImageButton,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.