using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Telerik.Web.UI;

public partial class RadGridTemplateColumnWithImageButton : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        DataTable dataTable = new DataTable();
        dataTable.Columns.Add("likes");
        dataTable.Columns.Add("liked");

        dataTable.Rows.Add(4, true);
        dataTable.Rows.Add(10, false);
        dataTable.Rows.Add(1, true);
        dataTable.Rows.Add(6, false);
        dataTable.Rows.Add(4, true);

        this.RadGrid1.DataSource = dataTable;
    }

    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
            ImageButton up_url = item.FindControl("vote_up") as ImageButton;
            ImageButton down_url = item.FindControl("vote_down") as ImageButton;

            if (bool.Parse(item.GetDataKeyValue("liked").ToString()))
            {
                up_url.ImageUrl = "~/images/up_no";
                down_url.ImageUrl = "~/images/down_no.png";
            }
            else
            {
                up_url.ImageUrl = "~/images/up_logo.png";
                down_url.ImageUrl = "~/images/down_logo.png";
            }
        }
    }
}