當前位置: 首頁>>代碼示例>>C#>>正文


C# DataTable.NewRow方法代碼示例

本文整理匯總了C#中System.Data.DataTable.NewRow方法的典型用法代碼示例。如果您正苦於以下問題:C# DataTable.NewRow方法的具體用法?C# DataTable.NewRow怎麽用?C# DataTable.NewRow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Data.DataTable的用法示例。


在下文中一共展示了DataTable.NewRow方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack) return;

            var datos = new DataTable();
            datos.Columns.Add("Nombre");
            datos.Columns.Add("Activo");

            var row = datos.NewRow();
            row["Nombre"] = "Palma";
            row["Activo"] = "Si";
            datos.Rows.Add(row);

            row = datos.NewRow();
            row["Nombre"] = "Caucho";
            row["Activo"] = "Si";
            datos.Rows.Add(row);

            row = datos.NewRow();
            row["Nombre"] = "Café";
            row["Activo"] = "Si";
            datos.Rows.Add(row);

            ViewState["Datos"] = datos;
            ViewState["ckbActivarFiltro"] = "";
        }
開發者ID:kenchic,項目名稱:SIMGA,代碼行數:26,代碼來源:uc_TipoCultivo.ascx.cs

示例2: MontarDadosFake

        private void MontarDadosFake()
        {
            var tabela1 = new DataTable("Talela1");
            tabela1.Columns.Add("col_a");
            tabela1.Columns.Add("col_b");
            tabela1.Columns.Add("col_c");
            this.ds.Tables.Add(tabela1);

            var tabela2 = new DataTable("Talela2");
            tabela2.Columns.Add("col_1");
            tabela2.Columns.Add("col_2");
            tabela2.Columns.Add("col_3");
            this.ds.Tables.Add(tabela2);

            var linha1 = tabela1.NewRow();
            tabela1.Rows.Add(linha1);
            linha1["col_a"] = "Edson";
            linha1["col_b"] = "Parizoti";
            linha1["col_c"] = "Junior";

            var linha1T2 = tabela2.NewRow();
            tabela2.Rows.Add(linha1T2);
            linha1T2["col_1"] = "C#";
            linha1T2["col_2"] = 50M;
            linha1T2["col_3"] = DateTime.Today;

            var linha2T2 = tabela2.NewRow();
            tabela2.Rows.Add(linha2T2);
            linha2T2["col_1"] = "Java";
            linha2T2["col_2"] = 50M;
            linha2T2["col_3"] = DateTime.Today.AddDays(5);
        }
開發者ID:lstern,項目名稱:practices,代碼行數:32,代碼來源:LeitorDeExcelTests.cs

示例3: ColumnInformationSave

        public ColumnInformationSave()
        {

            DataContext = this;
            InitializeComponent();
            SourceTable = new DataTable();
            SourceTable.Columns.Add(new DataColumn("GameName", typeof (string)));
            SourceTable.Columns.Add(new DataColumn("Creator", typeof (string)));
            SourceTable.Columns.Add(new DataColumn("Publisher", typeof (string)));
            SourceTable.Columns.Add(new DataColumn("Owner", typeof (string)));
            var row = SourceTable.NewRow();
            SourceTable.Rows.Add(row);
            row["GameName"] = "World Of Warcraft";
            row["Creator"] = "Blizzard";
            row["Publisher"] = "Blizzard";
            row["Owner"] = "Mark";
            row = SourceTable.NewRow();
            SourceTable.Rows.Add(row);
            row["GameName"] = "Halo";
            row["Creator"] = "Bungie";
            row["Publisher"] = "Microsoft";
            row["Owner"] = "Bill";
            row = SourceTable.NewRow();
            SourceTable.Rows.Add(row);
            row["GameName"] = "Gears Of War";
            row["Creator"] = "Epic";
            row["Publisher"] = "Microsoft";
            row["Owner"] = "Steve";
            codeViewer.LoadData("ColumnInformationSave");
        }
開發者ID:MuhammadUsmaann,項目名稱:Education-System-Desktop-App,代碼行數:30,代碼來源:ColumnInformationSave.xaml.cs

示例4: GetDelimitedStringTest

        public void GetDelimitedStringTest()
        {
            DataTable table = new DataTable();

            table.Columns.Add(new DataColumn("Column1", typeof(string)));
            table.Columns.Add(new DataColumn("Column2", typeof(int)));
            table.Columns.Add(new DataColumn("Column3", typeof(DateTime)));

            DataRow row = table.NewRow();
            table.Rows.Add(row);

            row["Column1"] = "Cell1";
            row["Column2"] = 1;
            row["Column3"] = DateTime.MinValue;

            row = table.NewRow();
            table.Rows.Add(row);

            row["Column1"] = "Cell2";
            row["Column2"] = 2;
            row["Column3"] = DateTime.MaxValue;

            DataView source = table.DefaultView; // TODO: Initialize to an appropriate value
            string rowDelimiter = "\r\n"; // TODO: Initialize to an appropriate value
            string columnDelimiter = ","; // TODO: Initialize to an appropriate value
            bool includeHeaders = true; // TODO: Initialize to an appropriate value
            string expected = "Column1,Column2,Column3\r\nCell1,1,1/1/0001 12:00:00 AM\r\nCell2,2,12/31/9999 11:59:59 PM"; // TODO: Initialize to an appropriate value
            string actual;
            actual = Extensions.GetDelimitedString(source, rowDelimiter, columnDelimiter, includeHeaders);
            Assert.AreEqual(expected, actual);
        }
開發者ID:middas,項目名稱:CommonLibrary,代碼行數:31,代碼來源:ExtensionsTest.cs

示例5: radGridReview_OnNeedDataSource

        protected void radGridReview_OnNeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("ReperenceNo");
            dt.Columns.Add("CustomerAccount");
            dt.Columns.Add("AmtLCY");
            dt.Columns.Add("AmtFCY");
            dt.Columns.Add("Status");
            dt.Columns.Add("LCCode");

            DataRow dr = dt.NewRow();
            dr["ReperenceNo"] = "TT/09161/078911";
            dr["CustomerAccount"] = "BANK OF SHANGHAI";
            dr["AmtLCY"] = "2,000,0000";
            dr["AmtFCY"] = "100.00";
            dr["Status"] = "UNA";
            dr["LCCode"] = "1";
            dt.Rows.Add(dr);

            DataRow dr1 = dt.NewRow();
            dr1["ReperenceNo"] = "TT/09161/078912";
            dr1["CustomerAccount"] = "CITI BANK NEWYORK";
            dr1["AmtLCY"] = "4,000,0000";
            dr1["AmtFCY"] = "200.00";
            dr1["Status"] = "UNA";
            dr1["LCCode"] = "2";
            dt.Rows.Add(dr1);

            radGridReview.DataSource = dt;
        }
開發者ID:nguyenppt,項目名稱:tfinance0115,代碼行數:30,代碼來源:CashWithdrawalsBuyingPreviewList.ascx.cs

示例6: SetCombo

 public void SetCombo(System.Windows.Forms.ComboBox Acombo)
 {
     DataTable workDT = new DataTable();
     DataRow row;
     ServVsel workDS = new ServVsel();
     workDT.Columns.Add("id", typeof(int));
     workDT.Columns.Add("desc");
     FillDS(workDS, selectionsql, new string[] { "tdbv_servsel" });
     foreach (ServVsel.tdbv_servselRow Rwork in workDS.tdbv_servsel)
     {
         row = workDT.NewRow();
         row["id"]   = Rwork.SERV_ID;
         row["desc"] = Rwork.BEZ;
         workDT.Rows.Add(row);
     }
     if (optional == true)
     {
         row = workDT.NewRow();
         row["id"]   = (int)-1;
         row["desc"] = "";
         workDT.Rows.Add(row);
     }
     Acombo.DataSource  = workDT;
     Acombo.DisplayMember = "desc";
     Acombo.ValueMember  = "id";
 }
開發者ID:oeli,項目名稱:yafra,代碼行數:26,代碼來源:Gservice.cs

示例7: Table_Define

        private DataTable Table_Define()
        {
            DataTable _Dt = new DataTable();

            DataColumn DC = new DataColumn();
            DC.ColumnName = "SiNo";
            _Dt.Columns.Add(DC);
            DC = new DataColumn();
            DC.ColumnName = "Name";
            _Dt.Columns.Add(DC);
            DC = new DataColumn();
            DC.ColumnName = "Status";
            _Dt.Columns.Add(DC);

            DataRow dr = _Dt.NewRow();
            dr[0] = "1";
            dr[1] = "New Application";
            dr[2] = "Passed";
            _Dt.Rows.Add(dr);

            dr = _Dt.NewRow();
            dr[0] = "2";
            dr[1] = "Eclipse Application";
            dr[2] = "Applied";
            _Dt.Rows.Add(dr);

            dr = _Dt.NewRow();
            dr[0] = "3";
            dr[1] = "Sigma Application";
            dr[2] = "Applied";
            _Dt.Rows.Add(dr);

            return _Dt;
        }
開發者ID:samhongithub,項目名稱:JQuery,代碼行數:34,代碼來源:Assignment3_grid.aspx.cs

示例8: axMapControl1_OnDoubleClick

        private void axMapControl1_OnDoubleClick(object sender, IMapControlEvents2_OnDoubleClickEvent e)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("name", typeof(string));
            dt.Columns.Add("value", typeof(string));

            DataRow dr = dt.NewRow();
            dr["name"] = "行政區";
            dr["value"] = "沈陽";
            dt.Rows.Add(dr);

            DataRow dr2 = dt.NewRow();
            dr2["name"] = "麵積";
            dr2["value"] = "1234.345";
            dt.Rows.Add(dr2);

            DataRow dr3 = dt.NewRow();
            dr3["name"] = "交通軌道長度";
            dr3["value"] = "1235.223";
            dt.Rows.Add(dr3);

            DataRow dr4 = dt.NewRow();
            dr4["name"] = "GDP總量";
            dr4["value"] = "234345";
            dt.Rows.Add(dr4);

            Control control = (Control)sender;
            System.Drawing.Point pt = control.PointToScreen(new System.Drawing.Point(e.x, e.y));
            frmMapFeatureAttr pFrmMapFeatureAttr = new frmMapFeatureAttr();
            pFrmMapFeatureAttr.AttrDataTable = dt;
            pFrmMapFeatureAttr.Location = pt;
            pFrmMapFeatureAttr.Show();
        }
開發者ID:BNU-Chen,項目名稱:CityPlanningView,代碼行數:33,代碼來源:ucMapControl.cs

示例9: SetCombo

 public void SetCombo(System.Windows.Forms.ComboBox Acombo)
 {
     DataTable workDT = new DataTable();
     DataRow row;
     string arrbez;
     ArrVsel workDS = new ArrVsel();
     workDT.Columns.Add("id", typeof(int));
     workDT.Columns.Add("desc");
     FillDS(workDS, selectionsql, new string[] { "tdbv_arrsel" });
     foreach (ArrVsel.tdbv_arrselRow Rwork in workDS.tdbv_arrsel)
     {
         arrbez = String.Format("{0} {1}", Rwork.BEZ, Rwork.ADAT.ToString());
         row = workDT.NewRow();
         row["id"]   = Rwork.ARR_ID;
         row["desc"] = arrbez;
         workDT.Rows.Add(row);
     }
     if (optional == true)
     {
         row = workDT.NewRow();
         row["id"]   = (int)-1;
         row["desc"] = "";
         workDT.Rows.Add(row);
     }
     Acombo.DataSource  = workDT;
     Acombo.DisplayMember = "desc";
     Acombo.ValueMember  = "id";
 }
開發者ID:oeli,項目名稱:yafra,代碼行數:28,代碼來源:Garr.cs

示例10: GetSubTotal

        private DataSet GetSubTotal()
        {
            var list = this.Horas;
            var dataSet = new DataSet();
            var table = new DataTable("table");
            System.Data.DataRow row;

            table.Columns.Add("nmFuncionario", Type.GetType("System.String"));
            table.Columns.Add("salario", Type.GetType("System.Decimal"));
            table.Columns.Add("porcentagem", Type.GetType("System.Decimal"));
            table.Columns.Add("flTipo", Type.GetType("System.String"));
            table.Columns.Add("hora", Type.GetType("System.TimeSpan"));
            table.Columns.Add("valor", Type.GetType("System.Decimal"));
            decimal? total = 0;
            foreach (var item in list.OrderByDescending(u => u.nmFuncionario))
            {
                row = table.NewRow();
                row["nmFuncionario"] = item.nmFuncionario;
                row["flTipo"] = item.flTipo;
                row["valor"] = item.valor;
                table.Rows.Add(row);
                row = table.NewRow();
                row["nmFuncionario"] = item.nmFuncionario;
                row["flTipo"] = "Valor do Descanso Semanal";
                row["valor"] = item.valor/26 * 5;
                table.Rows.Add(row);

            }

            dataSet.Tables.Add(table);
            return dataSet;
        }
開發者ID:odairkreuzberg,項目名稱:simetrica,代碼行數:32,代碼來源:HorasExtras.cs

示例11: UcQuarantineRecord

        public UcQuarantineRecord(IDBOperation dbOperation)
        {
            InitializeComponent();
            this.dbOperation = dbOperation;

            //檢疫員所屬部門貨主信息flag,屠宰場名稱,檢疫分站名稱
            DataTable table = dbOperation.GetDbHelper().GetDataSet("select ifnull(a.shipperflag,'') as shipperflag, " +
                                    " tzcname,INFO_NAME" +
                                    " from sys_client_sysdept a " +
                                    " where INFO_CODE = " + deptId).Tables[0];

            if (table.Rows.Count != 0)
            {
                shipperflag = table.Rows[0][0].ToString();
                _detect_site.Text = table.Rows[0][2].ToString();
                _slaughter_site.Text = table.Rows[0][1].ToString();
            }
            //申報人姓名
            ComboboxTool.InitComboboxSource(_shipper_name, string.Format("SELECT sbrid,sbrname FROM t_record_sbr WHERE openflag = '1' and createdeptid = '{0}'", deptId), "lr");
            //產地
            ComboboxTool.InitComboboxSource(_address, string.Format("SELECT areaid,areaname FROM t_record_area WHERE openflag = '1' and createdeptid = '{0}'", deptId), "lr");
            //協檢員
            ComboboxTool.InitComboboxSource(_help_user, string.Format("call p_user_helpuser({0})", userId), "lr");
            //官方獸醫姓名
            _user_name.Text = username;
            //錄入時間
            _entering_datetime.Text = string.Format("{0:g}", System.DateTime.Now);
            //屠宰動物種類
            ComboboxTool.InitComboboxSource(_animal, "SELECT animalid,animalname FROM t_animal_new WHERE openflag = '1' and deptflag = '" + shipperflag + "'", "lr");
            _animal.SelectionChanged += new SelectionChangedEventHandler(_animal_SelectionChanged);
            _animal.SelectedIndex = 1;
            //臨床情況
            DataTable dt_quater = new DataTable();
            dt_quater.Columns.Add(new DataColumn("quaterid"));
            dt_quater.Columns.Add(new DataColumn("quatername"));
            var row = dt_quater.NewRow();
            row["quaterid"] = "0";
            row["quatername"] = "良好";
            dt_quater.Rows.Add(row);
            var row2 = dt_quater.NewRow();
            row2["quaterid"] = "1";
            row2["quatername"] = "異常";
            dt_quater.Rows.Add(row2);
            ComboboxTool.InitComboboxSource(_quater, dt_quater, "lr");

            //是否佩戴規定的畜禽標識
            DataTable dt_object_flag = new DataTable();
            dt_object_flag.Columns.Add(new DataColumn("flagid"));
            dt_object_flag.Columns.Add(new DataColumn("flagname"));
            var row3 = dt_object_flag.NewRow();
            row3["flagid"] = "1";
            row3["flagname"] = "是";
            dt_object_flag.Rows.Add(row3);
            var row4 = dt_object_flag.NewRow();
            row4["flagid"] = "0";
            row4["flagname"] = "否";
            dt_object_flag.Rows.Add(row4);
            ComboboxTool.InitComboboxSource(_object_flag, dt_object_flag, "lr");

        }
開發者ID:wuqiangqiang,項目名稱:lnxcp,代碼行數:60,代碼來源:UcQuarantineRecord.xaml.cs

示例12: Display_HighScores

        public void Display_HighScores()
        {
            DataTable myTable = new DataTable();
            DataRow myNewRow = myTable.NewRow();
            int count = 1;

            myTable.Columns.Add("Rank", typeof(int));
            myTable.Columns.Add("Name", typeof(string));
            myTable.Columns.Add("Score", typeof(string));

            SqlConnection con = new SqlConnection("Data Source=KARL-PC;Initial Catalog=TestDB2;Integrated Security=True");
            con.Open();
            SqlCommand cmd = new SqlCommand("SELECT * FROM highscores_default ORDER BY score DESC", con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();

            da.Fill(dt);

            foreach (DataRow dr in dt.Rows)
            {
                if (count <= 10)
                {
                    myNewRow = myTable.NewRow();
                    myNewRow["Rank"] = count++;
                    myNewRow["Name"] = dr["name"].ToString();
                    myNewRow["Score"] = dr["score"].ToString();
                    myTable.Rows.Add(myNewRow);
                }
            }
            dataGridView1.AutoGenerateColumns = true;
            dataGridView1.DataSource = new BindingSource(myTable, null);
            con.Close();
        }
開發者ID:kludwigs,項目名稱:CSharpProjects,代碼行數:33,代碼來源:Form3.cs

示例13: BuildGrade

        protected void BuildGrade()
        {
            DataTable dtNew = new DataTable();
            dtNew.Columns.Add("DropdownText");
            dtNew.Columns.Add("Grade");
            dtNew.Columns.Add("CmbText");

            DataRow newRow = dtNew.NewRow();
            newRow["DropdownText"] = "All";
            newRow["Grade"] = "All";
            newRow["CmbText"] = "Grade";
            dtNew.Rows.Add(newRow);

            foreach (var sub in _alllcos.Select(lco => lco.Grade).Distinct().ToList())
            {
                newRow = dtNew.NewRow();
                newRow["DropdownText"] = sub;
                newRow["Grade"] = sub;
                newRow["CmbText"] = sub;
                dtNew.Rows.Add(newRow);
            }

            cmbGrade.DataTextField = "CmbText";
            cmbGrade.DataValueField = "Grade";
            cmbGrade.DataSource = dtNew;
            cmbGrade.DataBind();

            RadComboBoxItem item = this.cmbGrade.Items.FindItemByValue((String)this.ViewState[_gradeFilterKey], true) ?? this.cmbGrade.Items[0];
            ViewState[_gradeFilterKey] = item.Value;
            Int32 selIdx = cmbGrade.Items.IndexOf(item);
            cmbGrade.SelectedIndex = selIdx;
        }
開發者ID:ezimaxtechnologies,項目名稱:ASP.Net,代碼行數:32,代碼來源:CourseCatalog.ascx.cs

示例14: DT_Quy_QuyetToan

        public static DataTable DT_Quy_QuyetToan(Boolean All = true)
        {
            DataTable vR = new DataTable();
            vR.Columns.Add("MaQuy", typeof(String));
            vR.Columns.Add("TenQuy", typeof(String));

            DataRow R = vR.NewRow();
            R["MaQuy"] = "1";
            R["TenQuy"] = "Quý I";
            vR.Rows.InsertAt(R, 1);

            DataRow R1 = vR.NewRow();
            R1["MaQuy"] = "2";
            R1["TenQuy"] = "Quý II";
            vR.Rows.InsertAt(R1, 2);

            DataRow R2 = vR.NewRow();
            R2["MaQuy"] = "3";
            R2["TenQuy"] = "Quý III";
            vR.Rows.InsertAt(R2, 3);

            DataRow R4 = vR.NewRow();
            R4["MaQuy"] = "4";
            R4["TenQuy"] = "Quý IV";
            vR.Rows.InsertAt(R4, 4);

            if (All)
            {
                vR.Rows.InsertAt(vR.NewRow(), 0);
                vR.Rows[0]["MaQuy"] = "-1";
                vR.Rows[0]["TenQuy"] = "-- Quý --";
            }
            return vR;
        }
開發者ID:BMSProject2015,項目名稱:BMS,代碼行數:34,代碼來源:QLDA_DuToan_QuyModels.cs

示例15: Map

        public void Map()
        {
            DataTable dt = new DataTable();
            DataRow row = null;
            IDataReader dataReader = null;

            dt.Columns.Add(new DataColumn("id", typeof(int)));
            dt.Columns.Add(new DataColumn("name", typeof(string)));
            dt.Columns.Add(new DataColumn("prop01", typeof(int)));
            dt.Columns.Add(new DataColumn("unset"));
            row = dt.NewRow();
            row["id"] = 5;
            row["name"] = "idIs5";
            row["prop01"] = DBNull.Value;
            dt.Rows.Add(row);
            row = dt.NewRow();
            row["id"] = DBNull.Value;
            row["name"] = "idWithDBNull";
            row["prop01"] = 2;
            dt.Rows.Add(row);
            dataReader = dt.CreateDataReader();
            var entities = FieldMapper.Map<MyEntity01>(new FieldAdoDataReader(dataReader)).ToList();
            Assert.IsTrue(entities.Count == 2, "All entities are created");
            Assert.IsTrue(entities[0].Id == 5, "Field mapping of int is correct");
            Assert.IsTrue(entities[0].Name == "idIs5", "Field mapping of string is correct");
            Assert.IsTrue(entities[0].Prop01 == 99, "Field custom default value is set");
            Assert.IsTrue(entities[0].Unset == default(string), "Field decorated but not returned by the data source is mapped with type's default value");
            Assert.IsTrue(entities[0].UnsetWithDefaultValue == "unset", "Field decorated but not returned by the data source is mapped with field's default value");
            Assert.IsTrue(entities[0].IgnoreDecorated == default(string), "Field decorated with [Ignore] is ignored");
            Assert.IsTrue(entities[0].IgnoreNotDecorated == default(string), "Field not decorated with [Ignore] but not returned by the data source is ignored");
            Assert.IsTrue(entities[1].Id == default(int), "Field mapping of int with DBNull value is correct");
            Assert.IsTrue(entities[1].Prop01 == 2, "Field with default value is mapped with its' correct value if provided by the data source");
        }
開發者ID:monier,項目名稱:Monier,代碼行數:33,代碼來源:FieldAdoDataReaderTests.cs


注:本文中的System.Data.DataTable.NewRow方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。