برای ویرایش چک باکس از چه دستوری باید استفاده کنم؟
برا تکست از این استفاده می کنم
string cod = ((TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text;
متشکرم
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { int id= Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value.ToString()); string asm = ((TextBox)GridView1.Rows[e.RowIndex].Cells[0].Controls[0]).Text; string cod = ((TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text; string update = "UPDATE tblTest2 SET asm = '" + asm + "', cod = '" + cod + "' WHERE id = '" + id + "';"; SqlCommand command = new SqlCommand(update,Lib.con); Lib.con.Open(); command.ExecuteNonQuery(); Lib.con.Close(); GridView1.EditIndex = -1; BindGV1(); }
مشکل کجاست
مانند دستورات نام و کد مقدار CheckBox ها را نیز بگیرید
به جای Text از Value استفاده کنید
bool isChecked = (GridView1.Rows[0].Cells[2].Controls[0] as CheckBox).Checked;
عزیز عینا کپی نکنید باید شماره سلول را تغییر دهید
Cell را روی 4 بزارید
bool isChecked = (GridView1.Rows[e.RowIndex].Cells[0].Controls[2] as CheckBox).Checked;
string cod = ((TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text;
و
string cod = (GridView1.Rows[e.RowIndex].Cells[0].Controls[1] as TextBox).Text;
دوست من الان Cell روی 0 هست با چیزی که من در تصویر میبینم 0 نام است
string
cod = ((TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text;
و
string
cod = (GridView1.Rows[e.RowIndex].Cells[0].Controls[1]
as
TextBox).Text;
هیچ کاربری تا کنون از این پست تشکر نکرده است
با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)