积极答复者
C# 为什么没有执行这一步!

问题
-
下面这段代码是从界面的datagridview和控件里的提取数据并且存在实体类里,但是并没有执行给实体类赋值的语句。执行到黑体部分就跳至InsertproPlanInf(proPlanInfo)方法了!请问具体是怎么回事!
productionPlanEntiInfo proPlanInfo = new productionPlanEntiInfo(); ///实例化实体类
for (int i = 0; i < (int)this.dataGridView1.Tag; i++) ///tag初始值=0
{
proPlanInfo.Pp_Materil_Model = this.textBox1.Text.ToString();
proPlanInfo.Pp_Materil_ID = this.textBox2.Text.ToString();
proPlanInfo.Pp_Lot_Number = this.label6.Text.ToString();
proPlanInfo.Pp_Remarks = this.textBox9.Text.ToString();
proPlanInfo.Pp_End_Time = this.dateTimePicker2.Text.ToString();
proPlanInfo.Pp_Begin_Time = this.dateTimePicker1.Text.ToString();
proPlanInfo.Pp_Functionary = this.comboBox4.Text.ToString();
proPlanInfo.Pp_Department = this.comboBox5.Text.ToString();
proPlanInfo.Pp_Number = int.Parse(this.dataGridView1.Rows[i].Cells[2].Value.ToString());
proPlanInfo.Pp_Product_Model = this.dataGridView1.Rows[i].Cells[1].Value.ToString();
proPlanInfo.Pp_Product_Name = this.dataGridView1.Rows[i].Cells[0].Value.ToString();
}ppr.InsertproPlanInf(proPlanInfo);
MessageBox.Show("~添加成功~");- 已编辑 johnnyford 2010年10月13日 8:03 内容添加
答案
-
你好
或者你可以考慮用
for (int i = 0; i < (int)this.dataGridView1.RowCount; i++) ///tag初始值=0
試試看
Please correct me if my concept is wrong
Chi- 已标记为答案 johnnyford 2010年10月14日 0:56
全部回复
-
你好
或者你可以考慮用
for (int i = 0; i < (int)this.dataGridView1.RowCount; i++) ///tag初始值=0
試試看
Please correct me if my concept is wrong
Chi- 已标记为答案 johnnyford 2010年10月14日 0:56
-
你先打印输出一下(int)this.dataGridView1.Tag 的值,看看是否小于或等于0,如果是,那肯定跳出循环了。
这是写代码的良好习惯,时不时输出看看。
其实,VS作为IDE,调试是很方便的,你随时可以借助VS查看变量的变化情况。
http://www.cnblogs.com/2gua