Wednesday, January 4, 2023

How to add columns to datatable in ASP.NET C# - with string or int type

 DataTable dt = new DataAccess().Read(procName, param).Tables[0];

            dt.Columns.Add("cadrename", typeof(String));

            dt.Columns.Add("cadreID", typeof(int));

            foreach (DataRow item in dt.Rows)

            {

                item["cadrename"] = ddlCadreType.SelectedItem.Text;

                item["cadreID"] = ddlCadreType.SelectedValue;

            }

No comments:

Post a Comment