【发布时间】:2015-12-29 13:22:31
【问题描述】:
我正在尝试从两个不同且独立的 Telerik Gridview 获取数据。 (第一个用于客户,第二个用于编辑选定的客户)
我想从第一个客户 ID 中获取。我从以前的表单中创建了一个对象并尝试使其工作,但是当它想要获取最后一个表单的第一个元素时,它始终为 0。
Visual Studio 告诉我这个运行时错误
这是我在 3 个不同层中的代码
第一个
private void btnEdt_Click(object sender, EventArgs e)
{
Ref_View_Model = new View_model._View_Model();
Ref_C = new Customers();
foreach (var RowInfo in Ref_C.radGridView1.SelectedRows)
{
FireCell = RowInfo.Cells[0].Value.ToString();
}
Ref_C.radGridView1.CurrentRow.Delete();
Ref_C.customersTableAdapter.Update(Ref_C.sales_and_Inventory_SystemDataSet);
Ref_C.customersTableAdapter.Fill(Ref_C.sales_and_Inventory_SystemDataSet.Customers);
Ref_View_Model.GetEditCustomers(FireCell, txtFName.Text, txtLName.Text, txtPhn.Text, txtDdrss.Text);
第二层
public void GetEditCustomers(string _id,string _fName, string _lName, string _phone, string _address)
{
Ref_Model = new Model._Model();
Ref_Model.EditCustomres(_id, _fName, _lName, _phone, _address);
}
第三个
public void EditCustomres( string _id,string _fName, string _lName, string _phone, string _address)
{
Connection_String = @"Data Source=MOSTAFA-PC;Initial Catalog=" + "Sales and Inventory System" + ";Integrated Security=TrueData Source=MOSTAFA-PC;Initial Catalog=" + "Sales and Inventory System" + ";Integrated Security=True;";
Con = new SqlConnection();
Con.ConnectionString = Connection_String;
Helper = Convert.ToInt32(_id);
Con.Open();
Cmd = new SqlCommand();
Cmd.Connection = Con;
Cmd.CommandType = CommandType.Text;
Cmd.CommandText = "update Customers "+
"set FName=" + _fName + ",LName=" + _lName + ",Phone=" + _phone + ",[Address]=" + _address +
"where Id like " + Helper;
Cmd.ExecuteNonQuery();
Cmd.Dispose();
}
我不知道如何到达循环内的线路我尝试了 linq,但效果不佳
我该如何解决这个问题?
【问题讨论】: