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

namespace TicketID_176186
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindRadGrid();
            }
            else if (!radGridTest.EnableViewState)
            {
                BindRadGrid();
            }
        }

        private void BindRadGrid() 
    {
        radGridTest.DataSource = TFields;
        radGridTest.DataBind();
    }
        
    #region --- Table for Grid data ----------------------
    /// <summary>  
    /// Table for binding data to grid with 3 rows  
    /// </summary>  
    /// <value></value>  
    public DataTable TFields
    {
        get
        {
            if (a_tbFields == null)
            {
                a_tbFields = new DataTable("TESTTABLE");
                a_tbFields.Columns.Add("ID", System.Type.GetType("System.String")); //PrimKey  
                a_tbFields.Columns.Add("Name", System.Type.GetType("System.String"));
                a_tbFields.Columns.Add("Value", System.Type.GetType("System.String"));
                a_tbFields.Columns.Add("State", System.Type.GetType("System.String"));
                a_tbFields.Columns.Add("Message", System.Type.GetType("System.String"));
                a_tbFields.Columns.Add("MetaData", System.Type.GetType("System.String"));
                a_tbFields.Columns.Add("Variables", System.Type.GetType("System.String"));
                a_tbFields.Columns.Add("OrgValue", System.Type.GetType("System.String"));

                DataColumn[] columPrimKey = new DataColumn[1];
                columPrimKey[0] = a_tbFields.Columns["ID"];
                a_tbFields.PrimaryKey = columPrimKey;

                DataRow dr = a_tbFields.NewRow();
                dr["ID"] = NextPrimKey.ToString();
                dr["Name"] = "N1111";
                dr["Value"] = "V1111";
                dr["State"] = "S1111";
                dr["Message"] = "M1111";
                dr["MetaData"] = "W1111";
                dr["Variables"] = "V1111";
                dr["OrgValue"] = "O1111";
                TFields.Rows.Add(dr);

                dr = a_tbFields.NewRow();
                dr["ID"] = NextPrimKey.ToString();
                dr["Name"] = "N2222";
                dr["Value"] = "V2222";
                dr["State"] = "S2222";
                dr["Message"] = "M2222";
                dr["MetaData"] = "W2222";
                dr["Variables"] = "V2222";
                dr["OrgValue"] = "O2222";
                TFields.Rows.Add(dr);

                dr = a_tbFields.NewRow();
                dr["ID"] = NextPrimKey.ToString();
                dr["Name"] = "N3333";
                dr["Value"] = "V3333";
                dr["State"] = "S3333";
                dr["Message"] = "M3333";
                dr["MetaData"] = "W3333";
                dr["Variables"] = "V3333";
                dr["OrgValue"] = "O3333";
                TFields.Rows.Add(dr);
            }
            return a_tbFields;
        }
    }
    private DataTable a_tbFields = null;
    #endregion

    /// <summary>  
    /// artifical Primkey for Table  
    /// </summary>  
    public int NextPrimKey
    {
        set { a_oNextPrimKey = value; }
        get { return a_oNextPrimKey++; }
    }
    private int a_oNextPrimKey = 0;

    }
}
