با سلام
سلام من متوجه سوالتون نشدم ولی وقتی می خوام آیدی یه سطر رو بدست بیارم از این کد استفاده می کنم
int id = int.Parse(dgrcustomer.Rows[e.RowIndex].Cells[0].Value.ToString());
مثلا یه متدیه که قبلا ازش برای کارای خودم ازش استفاده کردم
public static void SelectCustomer(DataGridViewCellEventArgs e, DataGridView dgrcustomer, TextBox tid, TextBox tname, TextBox tmobile, TextBox ttell, TextBox temail, TextBox tdescription, Button btnupdate, Button btndelete) { btndelete.Enabled = true; btnupdate.Enabled = true; int id = int.Parse(dgrcustomer.Rows[e.RowIndex].Cells[0].Value.ToString()); try { if (e.ColumnIndex >= 0 && e.RowIndex >= 0) { using (CustomerDataContext selectCustomerDataContext = new CustomerDataContext()) { var objCustomer = selectCustomerDataContext.SelectCustomer(id).First(); tid.Text = objCustomer.CustomerId.ToString(); tname.Text = objCustomer.Name; ttell.Text = objCustomer.Tell; tmobile.Text = objCustomer.Mobile; temail.Text = objCustomer.Email; tdescription.Text = objCustomer.Discription; } } } catch (Exception) { MessageBox.Show("خطایی رخ داده است.", "خطا"); } }
هیچ کاربری تا کنون از این پست تشکر نکرده است
با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)