Monday, February 6, 2012

Bind Static Data to the Gridview in asp.net


protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                gvCertificates.DataSource = GVCertificate();
                gvCertificates.DataBind();
            }
            
        }

        public DataTable GVCertificate()
        {
            DataTable table = new DataTable();
           
            table.Columns.Add("CertificateType", typeof(string));
            table.Columns.Add("LinkedCertificateNum", typeof(string));
            table.Columns.Add("CertificateStatus", typeof(string));
            table.Columns.Add("CertificateTypeId", typeof(int));
                   
            table.Rows.Add("IC", "", "", 2);           
            table.Rows.Add("EXC", "", "", 3);
            table.Rows.Add("CSEC", "", "", 4);
            table.Rows.Add("CPIC", "", "", 5);   
            table.Rows.Add("FP", "", "", 6);
            table.Rows.Add("HVEC", "", "", 7);
            table.Rows.Add("RC", "", "", 8);
            table.Rows.Add("Norm", "", "", 9);
            table.Rows.Add("FPT", "", "", 10);
            if (TypeofRequest != string.Empty)
            {
                DataView dv = table.DefaultView;
                dv.RowFilter = "CertificateType <>'" + TypeofRequest + "'";              
            }         

            return table;

        }


No comments:

Post a Comment

Comments

Protected by Copyscape Plagiarism Software