J
John
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
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