using C1.Web.Wijmo.Controls.C1GridView;
using System;
using System.Data;
using System.Web.UI;

namespace GridView_Sample
{
    public partial class _Default : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                C1GridView1.DataSource = GetData();
                C1GridView1.DataBind();
            }
        }

        private DataTable GetData()
        {
            var dt = new DataTable();
            dt.Columns.Add("MonthNumber", typeof(int));
            dt.Columns.Add("I_string", typeof(object)); 
            dt.Columns.Add("I_integer", typeof(int)); 

            dt.Rows.Add(1, 1000, 1000);
            dt.Rows.Add(2, 25000, 25000);
            dt.Rows.Add(3, DBNull.Value, DBNull.Value);
            dt.Rows.Add(4, 45000, 45000);

            return dt;
        }

        protected void C1GridView1_RowDataBound(object sender, C1.Web.Wijmo.Controls.C1GridView.C1GridViewRowEventArgs e)
        {
            if (e.Row.RowType != C1.Web.Wijmo.Controls.C1GridView.C1GridViewRowType.DataRow)
                return;

            object value = DataBinder.Eval(e.Row.DataItem, "I_string");

            if (value != null && value != DBNull.Value)
            {
                if (decimal.TryParse(value.ToString(), out decimal num))
                {
                    // Column index 1 → second column ("I")
                    e.Row.Cells[1].Text = num.ToString("#,##0");
                }
            }
            else
            {
                e.Row.Cells[1].Text = string.Empty;
            }
        }
    }
}