PDA

View Full Version : اتصال به صورت زنجیری لیست باکس دیتا گرید ویو وتکس باکس



mohi_saboohi
جمعه 28 دی 1386, 21:43 عصر
سلام بچه ها من یک listbox رو با یک کلید خارجی به یک دیتا گرید ویوو چند textbox وصل کردم گ
به طوری که در رویداد کیلیک مربوط به listbox نوشتم :
SqlConnection Pcc0 = new SqlConnection(Cstr);
DataTable Pcdt0 = new DataTable();
SqlDataAdapter Pcda0 = new SqlDataAdapter();
Pcda0.SelectCommand = new SqlCommand();
Pcda0.SelectCommand.Connection = Pcc0;
Pcda0.SelectCommand.CommandText = "select * " + "FROM Created_goods " + " where (delet_statues = 'false') and (group_created_id) =" + GCID.Text.ToString();
Pcda0.SelectCommand.CommandType = CommandType.Text;
Pcc0.Open();
Pcda0.Fill(Pcdt0);
DataView Pcdv0 = new DataView(Pcdt0);
objCurrencyManager = (CurrencyManager)(this.BindingContext[Pcdv0]);
Pcc0.Close();
dataGridView2.DataSource = Pcdv0;
name.Text = dataGridView2.CurrentRow.Cells[1].ToString();
car.Text = dataGridView2.CurrentRow.Cells[4].ToString();
tipb.Text= dataGridView2.CurrentRow.Cells[12].ToString();
tips.Text = dataGridView2.CurrentRow.Cells[13].ToString();
des.Text = dataGridView2.CurrentRow.Cells[14].ToString();
buyingRate.Text = dataGridView2.CurrentRow.Cells[3].ToString();

به این ترتیب می خواهم تا اطلا عات به درون دیتا گرید ویو و تکس باکسها برود.
ولی می گوید نمونه ای از این شی(دیتا گرید ویو) موجود نیست.

sinpin
شنبه 29 دی 1386, 00:25 صبح
لطفا کدتون رو به شکل صحیح (با استفاده از تگ مربوطه) درج کنید :

SqlConnection Pcc0 = new SqlConnection(Cstr);
DataTable Pcdt0 = new DataTable();
SqlDataAdapter Pcda0 = new SqlDataAdapter();
Pcda0.SelectCommand = new SqlCommand();
Pcda0.SelectCommand.Connection = Pcc0;
Pcda0.SelectCommand.CommandText = "select * " + "FROM Created_goods " + " where (delet_statues = 'false') and (group_created_id) =" + GCID.Text.ToString();
Pcda0.SelectCommand.CommandType = CommandType.Text;
Pcc0.Open();
Pcda0.Fill(Pcdt0);
DataView Pcdv0 = new DataView(Pcdt0);
objCurrencyManager = (CurrencyManager)(this.BindingContext[Pcdv0]);
Pcc0.Close();
dataGridView2.DataSource = Pcdv0;
name.Text = dataGridView2.CurrentRow.Cells[1].ToString();
car.Text = dataGridView2.CurrentRow.Cells[4].ToString();
tipb.Text= dataGridView2.CurrentRow.Cells[12].ToString();
tips.Text = dataGridView2.CurrentRow.Cells[13].ToString();
des.Text = dataGridView2.CurrentRow.Cells[14].ToString();
buyingRate.Text = dataGridView2.CurrentRow.Cells[3].ToString();