Second ItemDataBound command does not fire

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When I execute the following code:

private void applicationPermissionGrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == System.Web.UI.WebControls.ListItemType.Item ||
(e.Item.ItemType ==
System.Web.UI.WebControls.ListItemType.AlternatingItem))
{
if (e.Item.Cells[6].Text == "0")
{
e.Item.Cells[0].Text = "NO";
e.Item.Cells[1].Text = "NO";
e.Item.Cells[2].Text = "NO";
e.Item.Cells[0].ForeColor = Color.Red;
e.Item.Cells[1].ForeColor = Color.Red;
e.Item.Cells[2].ForeColor = Color.Red;
}
else if (e.Item.Cells[6].Text == "1")
{
e.Item.Cells[0].Text = "YES";
e.Item.Cells[1].Text = "NO";
e.Item.Cells[2].Text = "NO";
e.Item.Cells[0].ForeColor = Color.Blue;
e.Item.Cells[1].ForeColor = Color.Red;
e.Item.Cells[2].ForeColor = Color.Red;
}

else if (e.Item.Cells[6].Text == "2")
{
e.Item.Cells[0].Text = "NO";
e.Item.Cells[1].Text = "YES";
e.Item.Cells[2].Text = "NO";
e.Item.Cells[0].ForeColor = Color.Red;
e.Item.Cells[1].ForeColor = Color.Blue;
e.Item.Cells[2].ForeColor = Color.Red;
}

else if (e.Item.Cells[6].Text == "3")
{
e.Item.Cells[0].Text = "YES";
e.Item.Cells[1].Text = "YES";
e.Item.Cells[2].Text = "NO";
e.Item.Cells[0].ForeColor = Color.Blue;
e.Item.Cells[1].ForeColor = Color.Blue;
e.Item.Cells[2].ForeColor = Color.Red;
}

else if (e.Item.Cells[6].Text == "4")
{
e.Item.Cells[0].Text = "NO";
e.Item.Cells[1].Text = "NO";
e.Item.Cells[2].Text = "YES";
e.Item.Cells[0].ForeColor = Color.Red;
e.Item.Cells[1].ForeColor = Color.Red;
e.Item.Cells[2].ForeColor = Color.Blue;
}
else if (e.Item.Cells[6].Text == "5")
{
e.Item.Cells[0].Text = "YES";
e.Item.Cells[1].Text = "NO";
e.Item.Cells[2].Text = "YES";
e.Item.Cells[0].ForeColor = Color.Blue;
e.Item.Cells[1].ForeColor = Color.Red;
e.Item.Cells[2].ForeColor = Color.Blue;
}

else if (e.Item.Cells[6].Text == "6")
{
e.Item.Cells[0].Text = "NO";
e.Item.Cells[1].Text = "YES";
e.Item.Cells[2].Text = "YES";
e.Item.Cells[0].ForeColor = Color.Red;
e.Item.Cells[1].ForeColor = Color.Blue;
e.Item.Cells[2].ForeColor = Color.Blue;
}

else if (e.Item.Cells[6].Text == "7")
{
e.Item.Cells[0].Text = "YES";
e.Item.Cells[1].Text = "YES";
e.Item.Cells[2].Text = "YES";
e.Item.Cells[0].ForeColor = Color.Blue;
e.Item.Cells[1].ForeColor = Color.Blue;
e.Item.Cells[2].ForeColor = Color.Blue;
}
}
}

private void tabPermissionGrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == System.Web.UI.WebControls.ListItemType.Item ||
(e.Item.ItemType ==
System.Web.UI.WebControls.ListItemType.AlternatingItem))
{
if (e.Item.Cells[4].Text == "8")
{
e.Item.Cells[0].Text = "YES";
e.Item.Cells[1].Text = "NO";
e.Item.Cells[0].ForeColor = Color.Blue;
e.Item.Cells[1].ForeColor = Color.Red;
}

else if (e.Item.Cells[4].Text == "16")
{
e.Item.Cells[0].Text = "NO";
e.Item.Cells[1].Text = "YES";
e.Item.Cells[0].ForeColor = Color.Red;
e.Item.Cells[1].ForeColor = Color.Blue;
}

else if (e.Item.Cells[4].Text == "24")
{
e.Item.Cells[0].Text = "YES";
e.Item.Cells[1].Text = "YES";
e.Item.Cells[0].ForeColor = Color.Blue;
e.Item.Cells[1].ForeColor = Color.Blue;
}
}
}

The ItemDataBound command for the tabPermissionGrid does not fire. The one
for the applicationPermissionGrid works fine. What could be causing the
problem?

Thanks,

Dave
 
You don't show the code you use to attach the handler of the event to the
procedure. Everything you show here is not useful to solving your problem.

Note: You use this code if(e.Item.Cells[6].Text == "X") a lot. It would
improve readablilty to use a select case statement.

Chris

kscdavefl said:
When I execute the following code:

private void applicationPermissionGrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == System.Web.UI.WebControls.ListItemType.Item ||
(e.Item.ItemType ==
System.Web.UI.WebControls.ListItemType.AlternatingItem))
{
if (e.Item.Cells[6].Text == "0")
{
e.Item.Cells[0].Text = "NO";
e.Item.Cells[1].Text = "NO";
e.Item.Cells[2].Text = "NO";
e.Item.Cells[0].ForeColor = Color.Red;
e.Item.Cells[1].ForeColor = Color.Red;
e.Item.Cells[2].ForeColor = Color.Red;
}
else if (e.Item.Cells[6].Text == "1")
{
e.Item.Cells[0].Text = "YES";
e.Item.Cells[1].Text = "NO";
e.Item.Cells[2].Text = "NO";
e.Item.Cells[0].ForeColor = Color.Blue;
e.Item.Cells[1].ForeColor = Color.Red;
e.Item.Cells[2].ForeColor = Color.Red;
}

else if (e.Item.Cells[6].Text == "2")
{
e.Item.Cells[0].Text = "NO";
e.Item.Cells[1].Text = "YES";
e.Item.Cells[2].Text = "NO";
e.Item.Cells[0].ForeColor = Color.Red;
e.Item.Cells[1].ForeColor = Color.Blue;
e.Item.Cells[2].ForeColor = Color.Red;
}

else if (e.Item.Cells[6].Text == "3")
{
e.Item.Cells[0].Text = "YES";
e.Item.Cells[1].Text = "YES";
e.Item.Cells[2].Text = "NO";
e.Item.Cells[0].ForeColor = Color.Blue;
e.Item.Cells[1].ForeColor = Color.Blue;
e.Item.Cells[2].ForeColor = Color.Red;
}

else if (e.Item.Cells[6].Text == "4")
{
e.Item.Cells[0].Text = "NO";
e.Item.Cells[1].Text = "NO";
e.Item.Cells[2].Text = "YES";
e.Item.Cells[0].ForeColor = Color.Red;
e.Item.Cells[1].ForeColor = Color.Red;
e.Item.Cells[2].ForeColor = Color.Blue;
}
else if (e.Item.Cells[6].Text == "5")
{
e.Item.Cells[0].Text = "YES";
e.Item.Cells[1].Text = "NO";
e.Item.Cells[2].Text = "YES";
e.Item.Cells[0].ForeColor = Color.Blue;
e.Item.Cells[1].ForeColor = Color.Red;
e.Item.Cells[2].ForeColor = Color.Blue;
}

else if (e.Item.Cells[6].Text == "6")
{
e.Item.Cells[0].Text = "NO";
e.Item.Cells[1].Text = "YES";
e.Item.Cells[2].Text = "YES";
e.Item.Cells[0].ForeColor = Color.Red;
e.Item.Cells[1].ForeColor = Color.Blue;
e.Item.Cells[2].ForeColor = Color.Blue;
}

else if (e.Item.Cells[6].Text == "7")
{
e.Item.Cells[0].Text = "YES";
e.Item.Cells[1].Text = "YES";
e.Item.Cells[2].Text = "YES";
e.Item.Cells[0].ForeColor = Color.Blue;
e.Item.Cells[1].ForeColor = Color.Blue;
e.Item.Cells[2].ForeColor = Color.Blue;
}
}
}

private void tabPermissionGrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == System.Web.UI.WebControls.ListItemType.Item ||
(e.Item.ItemType ==
System.Web.UI.WebControls.ListItemType.AlternatingItem))
{
if (e.Item.Cells[4].Text == "8")
{
e.Item.Cells[0].Text = "YES";
e.Item.Cells[1].Text = "NO";
e.Item.Cells[0].ForeColor = Color.Blue;
e.Item.Cells[1].ForeColor = Color.Red;
}

else if (e.Item.Cells[4].Text == "16")
{
e.Item.Cells[0].Text = "NO";
e.Item.Cells[1].Text = "YES";
e.Item.Cells[0].ForeColor = Color.Red;
e.Item.Cells[1].ForeColor = Color.Blue;
}

else if (e.Item.Cells[4].Text == "24")
{
e.Item.Cells[0].Text = "YES";
e.Item.Cells[1].Text = "YES";
e.Item.Cells[0].ForeColor = Color.Blue;
e.Item.Cells[1].ForeColor = Color.Blue;
}
}
}

The ItemDataBound command for the tabPermissionGrid does not fire. The
one
for the applicationPermissionGrid works fine. What could be causing the
problem?

Thanks,

Dave
 
Chris said:
You don't show the code you use to attach the handler of the event to the
procedure. Everything you show here is not useful to solving your problem.

Note: You use this code if(e.Item.Cells[6].Text == "X") a lot. It would
improve readablilty to use a select case statement.

Chris

kscdavefl said:
When I execute the following code:

private void applicationPermissionGrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == System.Web.UI.WebControls.ListItemType.Item ||
(e.Item.ItemType ==
System.Web.UI.WebControls.ListItemType.AlternatingItem))
{
if (e.Item.Cells[6].Text == "0")
{
e.Item.Cells[0].Text = "NO";
e.Item.Cells[1].Text = "NO";
e.Item.Cells[2].Text = "NO";
e.Item.Cells[0].ForeColor = Color.Red;
e.Item.Cells[1].ForeColor = Color.Red;
e.Item.Cells[2].ForeColor = Color.Red;
}
else if (e.Item.Cells[6].Text == "1")
{
e.Item.Cells[0].Text = "YES";
e.Item.Cells[1].Text = "NO";
e.Item.Cells[2].Text = "NO";
e.Item.Cells[0].ForeColor = Color.Blue;
e.Item.Cells[1].ForeColor = Color.Red;
e.Item.Cells[2].ForeColor = Color.Red;
}

else if (e.Item.Cells[6].Text == "2")
{
e.Item.Cells[0].Text = "NO";
e.Item.Cells[1].Text = "YES";
e.Item.Cells[2].Text = "NO";
e.Item.Cells[0].ForeColor = Color.Red;
e.Item.Cells[1].ForeColor = Color.Blue;
e.Item.Cells[2].ForeColor = Color.Red;
}

else if (e.Item.Cells[6].Text == "3")
{
e.Item.Cells[0].Text = "YES";
e.Item.Cells[1].Text = "YES";
e.Item.Cells[2].Text = "NO";
e.Item.Cells[0].ForeColor = Color.Blue;
e.Item.Cells[1].ForeColor = Color.Blue;
e.Item.Cells[2].ForeColor = Color.Red;
}

else if (e.Item.Cells[6].Text == "4")
{
e.Item.Cells[0].Text = "NO";
e.Item.Cells[1].Text = "NO";
e.Item.Cells[2].Text = "YES";
e.Item.Cells[0].ForeColor = Color.Red;
e.Item.Cells[1].ForeColor = Color.Red;
e.Item.Cells[2].ForeColor = Color.Blue;
}
else if (e.Item.Cells[6].Text == "5")
{
e.Item.Cells[0].Text = "YES";
e.Item.Cells[1].Text = "NO";
e.Item.Cells[2].Text = "YES";
e.Item.Cells[0].ForeColor = Color.Blue;
e.Item.Cells[1].ForeColor = Color.Red;
e.Item.Cells[2].ForeColor = Color.Blue;
}

else if (e.Item.Cells[6].Text == "6")
{
e.Item.Cells[0].Text = "NO";
e.Item.Cells[1].Text = "YES";
e.Item.Cells[2].Text = "YES";
e.Item.Cells[0].ForeColor = Color.Red;
e.Item.Cells[1].ForeColor = Color.Blue;
e.Item.Cells[2].ForeColor = Color.Blue;
}

else if (e.Item.Cells[6].Text == "7")
{
e.Item.Cells[0].Text = "YES";
e.Item.Cells[1].Text = "YES";
e.Item.Cells[2].Text = "YES";
e.Item.Cells[0].ForeColor = Color.Blue;
e.Item.Cells[1].ForeColor = Color.Blue;
e.Item.Cells[2].ForeColor = Color.Blue;
}
}
}

private void tabPermissionGrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == System.Web.UI.WebControls.ListItemType.Item ||
(e.Item.ItemType ==
System.Web.UI.WebControls.ListItemType.AlternatingItem))
{
if (e.Item.Cells[4].Text == "8")
{
e.Item.Cells[0].Text = "YES";
e.Item.Cells[1].Text = "NO";
e.Item.Cells[0].ForeColor = Color.Blue;
e.Item.Cells[1].ForeColor = Color.Red;
}

else if (e.Item.Cells[4].Text == "16")
{
e.Item.Cells[0].Text = "NO";
e.Item.Cells[1].Text = "YES";
e.Item.Cells[0].ForeColor = Color.Red;
e.Item.Cells[1].ForeColor = Color.Blue;
}

else if (e.Item.Cells[4].Text == "24")
{
e.Item.Cells[0].Text = "YES";
e.Item.Cells[1].Text = "YES";
e.Item.Cells[0].ForeColor = Color.Blue;
e.Item.Cells[1].ForeColor = Color.Blue;
}
}
}

The ItemDataBound command for the tabPermissionGrid does not fire. The
one
for the applicationPermissionGrid works fine. What could be causing the
problem?

Thanks,

Dave

The applicationPermissionGrid_ItemdataBoundCommand event fires when the grid is first loadded. However, the tabPermissionGrid loads but does not recognize the ItemdataBound command at all.
 
Back
Top