Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > ImageButton not firing ItemCommand event for the datagrid

Reply
Thread Tools

ImageButton not firing ItemCommand event for the datagrid

 
 
John
Guest
Posts: n/a
 
      08-04-2005
Hey guys, i have 2 datagrids on a page that are shown and hidden using
component one tabs and topic bars and stuff like that. the original grid
works fine, but the second grid i added works just like it should except that
when you click one of the 4 image buttons( not all of them are visible at
the same time and 2 call javascript confirm functions onClick) they dont fire
the ItemCommand event of my datagrid they just postback and dont do anything
except display the confirm boxes. i have looked in the code that .NET
InitializeComonent function and the first dg is listed but the second is not.
the itemdatabound fucntion on the second grid fires and works, but its not
listed here and even when they are listed(i added them once) it didnt change
anything ItemDataBound worked perfectly, but ItemCommand get ignored. in the
datagrid delceration in the html i do assign these funciton to their
respective events.

thanks for all the help

ItemCommand Function:
protected void dgEmailResults_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
Trace.Write("e.CommandName=" + e.CommandName);
Trace.Write("e.CommandArgument=" + e.CommandArgument);

// get the item's broadcastID
int broadcastID = int.Parse(e.CommandArgument.ToString());

// fire the appropriate method
switch (e.CommandName)
{
case "Resume":
resumeEmailBroadcast(broadcastID);
break;
case "Pause":
pauseEmailBroadcast(broadcastID);
break;
case "Stop":
killEmailBroadcast(broadcastID);
break;
case "Retry":
retryEmailBroadcast(broadcastID);
break;
}

// update the table
bindGrid();
}
ItemDataBound:

protected void dgEmailResults_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
// make sure this is an Item or an AlternatingItem row
ListItemType myType = (ListItemType)e.Item.ItemType;
Trace.Write("itemdatabound");
if (myType == ListItemType.Item || myType == ListItemType.AlternatingItem)
{

// get instances of each button
ImageButton btnEmailStop =
(ImageButton)e.Item.FindControl("btnEmailStop");
ImageButton btnEmailRetry =
(ImageButton)e.Item.FindControl("btnEmailRetry");
ImageButton btnEmailPause =
(ImageButton)e.Item.FindControl("btnEmailPause");
ImageButton btnEmailResume =
(ImageButton)e.Item.FindControl("btnEmailResume");
// add the 'onclick' client-side handlers to each button
btnEmailStop.Attributes.Add("onclick", "return confirmKill();");
btnEmailRetry.Attributes.Add("onclick", "return confirmRetry();");

// turn all buttons off, then turn the appropriate buttons on
btnEmailStop.Visible = false;
btnEmailRetry.Visible = false;
btnEmailPause.Visible = false;
btnEmailResume.Visible = false;

switch (int.Parse(DataBinder.Eval(e.Item.DataItem,
"EMailBroadcastStatusId").ToString()))
{
case 0:
btnEmailResume.Visible = true;
btnEmailStop.Visible = true;
break;
case 1:
case 2:
btnEmailStop.Visible = true;
btnEmailPause.Visible = true;
break;
default:
btnEmailRetry.Visible = true;
break;
}//end switch
}//end if
}//end item databound

 
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
ImageButton does not trigger Repeater.ItemCommand event Nathan Sokalski ASP .Net 2 11-17-2007 03:03 AM
Event ItemCommand not firing in DataGrid (1.1) Andy ASP .Net 0 01-10-2007 12:07 AM
DataGrid ItemCommand event not firing if not first page =?Utf-8?B?ZGFuYw==?= ASP .Net 3 10-26-2005 05:24 PM
Datagrid ItemCommand Event Not Firing =?Utf-8?B?RGVlcGVzaA==?= ASP .Net 2 10-06-2005 12:46 AM
Dynamic Datagrid Creation - ItemCommand event not firing PD ASP .Net Datagrid Control 0 10-23-2003 03:48 PM



Advertisments