This is a migrated thread and some comments may be shown as answers.

Last row not updating

2 Answers 21 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 02 Oct 2013, 03:07 PM
I'm using the item databound event in radgrid to look at a status column and to change another column's font color and set it to bold if the status equals 3.  This works perfectly fine on all of the rows except for the last row.  Is there anything you can see with this code example that I'm missing to get this to apply to the last row as well?

        protected void rgGrid_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                foreach (GridDataItem item in rgGrid.Items)
                {
                    Label sunstat = item["sunstat"].FindControl("lbliSundayStat") as Label;
                    Label monstat = item["monstat"].FindControl("lbliMondayStat") as Label;
                    Label tuestat = item["tuestat"].FindControl("lbliTuesdayStat") as Label;
                    Label wedstat = item["wedstat"].FindControl("lbliSundayStat") as Label;
                    Label thustat = item["thustat"].FindControl("lbliSundayStat") as Label;
                    Label fristat = item["fristat"].FindControl("lbliSundayStat") as Label;
                    Label satstat = item["satstat"].FindControl("lbliSundayStat") as Label;

                    Label sun = item["Sunday"].FindControl("lbliSunday") as Label;
                    Label mon = item["Monday"].FindControl("lbliMonday") as Label;
                    Label tue = item["Tuesday"].FindControl("lbliTuesday") as Label;
                    Label wed = item["Wednesday"].FindControl("lbliWednesday") as Label;
                    Label thu = item["Thursday"].FindControl("lbliThursday") as Label;
                    Label fri = item["Friday"].FindControl("lbliFriday") as Label;
                    Label sat = item["Saturday"].FindControl("lbliSaturday") as Label;
                    if (sunstat.Text == "3")
                    {
                        sun.ForeColor = Color.Red;
                        sun.Font.Bold = true;
                    }
                    if (monstat.Text == "3")
                    {
                        mon.ForeColor = Color.Red;
                        mon.Font.Bold = true;
                    }
                    if (tuestat.Text == "3")
                    {
                        tue.ForeColor = Color.Red;
                        tue.Font.Bold = true;
                    }
                    if (wedstat.Text == "3")
                    {
                        wed.ForeColor = Color.Red;
                        wed.Font.Bold = true;
                    }
                    if (thustat.Text == "3")
                    {
                        thu.ForeColor = Color.Red;
                        thu.Font.Bold = true;
                    }
                    if (fristat.Text == "3")
                    {
                        fri.ForeColor = Color.Red;
                        fri.Font.Bold = true;
                    }
                    if (satstat.Text == "3")
                    {
                        sat.ForeColor = Color.Red;
                        sat.Font.Bold = true;
                    }
                }
}

2 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 03 Oct 2013, 05:11 AM
Hello,

Please try with the below code snippet.

protected void rgGrid_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
 
            Label sunstat = item["sunstat"].FindControl("lbliSundayStat") as Label;
            Label monstat = item["monstat"].FindControl("lbliMondayStat") as Label;
            Label tuestat = item["tuestat"].FindControl("lbliTuesdayStat") as Label;
            Label wedstat = item["wedstat"].FindControl("lbliSundayStat") as Label;
            Label thustat = item["thustat"].FindControl("lbliSundayStat") as Label;
            Label fristat = item["fristat"].FindControl("lbliSundayStat") as Label;
            Label satstat = item["satstat"].FindControl("lbliSundayStat") as Label;
 
            Label sun = item["Sunday"].FindControl("lbliSunday") as Label;
            Label mon = item["Monday"].FindControl("lbliMonday") as Label;
            Label tue = item["Tuesday"].FindControl("lbliTuesday") as Label;
            Label wed = item["Wednesday"].FindControl("lbliWednesday") as Label;
            Label thu = item["Thursday"].FindControl("lbliThursday") as Label;
            Label fri = item["Friday"].FindControl("lbliFriday") as Label;
            Label sat = item["Saturday"].FindControl("lbliSaturday") as Label;
            if (sunstat.Text == "3")
            {
                sun.ForeColor = Color.Red;
                sun.Font.Bold = true;
            }
            if (monstat.Text == "3")
            {
                mon.ForeColor = Color.Red;
                mon.Font.Bold = true;
            }
            if (tuestat.Text == "3")
            {
                tue.ForeColor = Color.Red;
                tue.Font.Bold = true;
            }
            if (wedstat.Text == "3")
            {
                wed.ForeColor = Color.Red;
                wed.Font.Bold = true;
            }
            if (thustat.Text == "3")
            {
                thu.ForeColor = Color.Red;
                thu.Font.Bold = true;
            }
            if (fristat.Text == "3")
            {
                fri.ForeColor = Color.Red;
                fri.Font.Bold = true;
            }
            if (satstat.Text == "3")
            {
                sat.ForeColor = Color.Red;
                sat.Font.Bold = true;
            }
        }
    }


Thanks,
Jayesh Goyani
0
John
Top achievements
Rank 1
answered on 03 Oct 2013, 01:28 PM
Thank You Jayesh,

That worked for me.

John
Tags
Grid
Asked by
John
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
John
Top achievements
Rank 1
Share this question
or