Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Capturing template button events in a datagrid???

Posted on 2004-04-20
3
Medium Priority
?
947 Views
Last Modified: 2007-12-19
Hi all.
I created a web form with a datagrid and I added templates to the grid with custom image buttons for row edit, delete, update, and cancel actions.
But I have not been able to capture any events for those image buttons.
If I don't use the template buttons and just use grid default edit, update, cancel button column instead, then everything works fine with DataGrid_EditCommnad, DataGrid_UpdateCommand, and DataGrid_CancelCommand events handle procedures.
Is anyone able to explain how to capture events from those template image buttons.
Thanks.
0
Comment
Question by:soweyoung
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Expert Comment

by:dante469
ID: 10869541
Pressing the image button in the template column would be accessable as follows (example image button id is ibtnTemplateCol)....

---.ASPX---->
<asp:ImageButton id="ibtnTemplateCol" runat="server" ImageUrl="http://www.experts-exchange.com/images/vipAccess.gif" OnClick="ibtnTemplateCol_C"></asp:ImageButton>

---Codebehind---->  'Notice the sub is NOT private
Sub ibtnTemplateCol_C(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs)
        Dim sWorld As String = "From iButton in Template Column"
        Response.Write(sWorld)
End Sub

Have fun,
Dante
0
 
LVL 20

Accepted Solution

by:
ihenry earned 375 total points
ID: 10869890
using ItemCommand event,

--- ASPX ---
<asp:datagrid AutoGenerateColumns="False" >
<Columns>
     <asp:TemplateColumn>
          <ItemTemplate>
               <asp:ImageButton AlternateText="Delete this item" CausesValidation="False" CommandName="Delete" ImageUrl="~/images/delete.gif" Runat="server"></asp:ImageButton>
          </ItemTemplate>
     </asp:TemplateColumn>
</Columns>
</asp:datagrid>

--- ASPX.VB --
Sub DataGrid1_ItemCommand( sender As Object, e As DataGridCommandEventArgs )

     If ( e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem )

          If ( e.CommandName = "Delete ")
               ' the image button is pressed..
          End If

     End If
 End Sub
0
 
LVL 20

Expert Comment

by:ihenry
ID: 10869982
Or this article should be able to explain better,

Allowing Users to Select Items in a DataGrid Control
http://authors.aspalliance.com/aspxtreme/webforms/controls/allowinguserstoselectitemsindatagrid.aspx
0

Featured Post

Not sure which OpenStack Certification to get?

So you’ve realized you might want to get certified in OpenStack, but you’re not sure what the benefits might be or even which one you should take. You know there are several certification courses you can choose from, but how do you know which one is right for you?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question