T
Trond
I have an ASP.NET page that is displaying data from a dataset in a datagrid.
All columns are bound. In code behind file i use ItemDataBound event to do
some formatting of some off the columns. Insted of changing the
cell.BackColor = Color.Green; i want to add a checkbox and set it to checked
if true and unchecked if not ( in the else loop). Is this possible?
Best regards
Trond
private void dgMessages_ItemDataBound_1(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
try
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
TableCell cell = e.Item.Cells[7];
long Timediff = long.Parse(cell.Text);
if (Timediff == 1 || Timediff == 3 || Timediff == 5 || Timediff == 7 ||
Timediff == 9 || Timediff==11 || Timediff == 13 ||Timediff == 15 )
{
cell.BackColor = Color.Green;
cell.Text="OK";
}
else
{
cell.BackColor = Color.Red;
cell.Text="-";
}
All columns are bound. In code behind file i use ItemDataBound event to do
some formatting of some off the columns. Insted of changing the
cell.BackColor = Color.Green; i want to add a checkbox and set it to checked
if true and unchecked if not ( in the else loop). Is this possible?
Best regards
Trond
private void dgMessages_ItemDataBound_1(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
try
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
TableCell cell = e.Item.Cells[7];
long Timediff = long.Parse(cell.Text);
if (Timediff == 1 || Timediff == 3 || Timediff == 5 || Timediff == 7 ||
Timediff == 9 || Timediff==11 || Timediff == 13 ||Timediff == 15 )
{
cell.BackColor = Color.Green;
cell.Text="OK";
}
else
{
cell.BackColor = Color.Red;
cell.Text="-";
}