Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > What doesn't an ItemTemplate child control fire an ItemCommand??

Reply
Thread Tools

What doesn't an ItemTemplate child control fire an ItemCommand??

 
 
Mark Sisson
Guest
Posts: n/a
 
      12-17-2003
Could someone explain to me why my first column in my datagrid below
doesn't fire the event while the second column does??? I don't
understand why controls within an item template that have a
CommandName don't go anywhere. What's the point?? Do you have to use
ButtonColumns to fire events???

TIA

===========RELAVENT ASPX CODE============
<aspataGrid id="grdMain"AutoGenerateColumns="False"
DataKeyField="orderid">
<Columns>
<asp:BoundColumn DataField="orderid"
HeaderText="orderid"></asp:BoundColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:ImageButton id="ImageButton1" runat="server"
CommandName="Select" ImageUrl="images/edit.gif"></asp:ImageButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:ButtonColumn runat='server' Text='<img border=0
src="images/edit.gif">' CommandName=Select>
</asp:ButtonColumn>
</Columns>
</aspataGrid>


===========ASPX CODEBEHIND ============
using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace LandmarkIntranetPortal
{
/// <summary>
/// Summary description for Test.
/// </summary>
public class Test : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid grdMain;

private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection con = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand cmd = new SqlCommand("select * from [order]",con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
grdMain.DataSource = ds;
grdMain.DataBind();
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web
//Form Designer.
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.grdMain.ItemCommand += new
System.Web.UI.WebControls.DataGridCommandEventHand ler(this.grdMain_ItemCommand);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void grdMain_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
Debug.Write("here!!!");
}
}
}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Parent/Child relations - Trying to access child control for save tnt_lu@hotmail.com ASP .Net Datagrid Control 0 04-15-2005 12:50 PM
can code inside a Repeater's ItemTemplate modify controls in the ItemTemplate? Bennett Haselton ASP .Net 1 09-24-2004 01:59 AM
Child Control Won't Fire "OnPreRender" Chad Stoker ASP .Net Web Controls 0 06-08-2004 06:16 PM
Placeholder child of child control event problem. caldera ASP .Net Building Controls 1 05-28-2004 07:56 AM
How do I: Main thread spawn child threads, which child processes...control those child processes? Jeff Rodriguez C Programming 23 12-09-2003 11:06 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57