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

namespace GridView_RowsSample
{
    public partial class _Default : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                C1GridView1.DataSource = new DataTable()
                {
                    Columns = { "Id", "Name", "Desc" },
                    Rows =
                    {
                        {1, "name-1", "desc-1" },
                        {2, "name-2", "desc-2" },
                        {3, "name-3", "desc-3" }
                    }
                };
                C1GridView1.DataBind();
            }
        }

        protected void C1GridView1_RowDataBound(object sender, C1.Web.Wijmo.Controls.C1GridView.C1GridViewRowEventArgs e)
        {
            if (e.Row.RowType == C1.Web.Wijmo.Controls.C1GridView.C1GridViewRowType.DataRow)
            {
                var rowData = (DataRowView)e.Row.DataItem;
                var tripJson = "{\"id\":" + rowData["Id"] + ",\"name\":\"" + rowData["Name"] + "\"}";
                e.Row.Attributes["trip"] = tripJson;
            }
        }
    }
}