473,659 Members | 2,836 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:TemplateCo lumn>
<ItemTemplate >
<asp:LinkButt on runat="server" Text="Delete" CommandName="De lete"
CausesValidatio n="false"></asp:LinkButton>
</ItemTemplate> </asp:TemplateCol umn>

To this:

<asp:TemplateCo lumn>
<ItemTemplate >
<asp:ImageButto n runat="server" ImageURL="image s/test.gif"
CommandName="De lete" CausesValidatio n="false"></asp:ImageButton >
</ItemTemplate> </asp:TemplateCol umn>

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 3406
Hi Matt,

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

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

HTH

Elton Wang
el********@hotm ail.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:TemplateCo lumn>
<ItemTemplate >
<asp:LinkButt on runat="server" Text="Delete" CommandName="De lete"
CausesValidatio n="false"></asp:LinkButton>
</ItemTemplate> </asp:TemplateCol umn>

To this:

<asp:TemplateCo lumn>
<ItemTemplate >
<asp:ImageButto n runat="server" ImageURL="image s/test.gif"
CommandName="De lete" CausesValidatio n="false"></asp:ImageButton >
</ItemTemplate> </asp:TemplateCol umn>

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
353
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 Not"> <ItemTemplate> <!--<asp:ImageButton ID="btnViewReply" Runat="server" CommandName="btnViewReply" ImageUrl='<%# selectimage(DataBinder.Eval(Container.DataItem, "spec_hold_status"),
2
3628
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 a row. Everything works just fine. BUT I would like to add a button to (for example) the DataGrid header, which when pressed will add a new row to the datagrid. This should then allow the user to enter information into text boxes (in some...
1
5705
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, using C# Codebehind. (I want a ImageButton column :-) ) ..Javier Ros Moreno.
2
2097
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 function: btnDelete.Attributes.Add("onClick", "if(confirm('Are you sure you want to delete this order?')){}else{return false}");
0
1236
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 the code for my inner datagrid's EditCommand: public void dgInner_EditCommand(object sender, DataGridCommandEventArgs e) {
4
6941
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
3237
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 that button? I don't want to have to add a AddHandler in the ItemCreated or ItemDataBound for this ImageButton cause then I can't get the ID from the Row to delete as easy...
2
1607
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 event, I need to reference the contents of a cell within the record currently in edit mode. For example... The datagrid has 3 columns: ID, Name, Picture When placed in edit mode my asp:ImageButton appears in the Picture column, and the ID and Name...
3
1952
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, how can I tell which row he clicked on, and then change the image for the ImageButton in that row, and make sure all the images in the other rows are default? I have two Images, one of a button in the "Up" position, and another of the same...
0
8332
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.