Hello guys. For the past two days I have been trying to research
how in 05 can you pull the value from a gridview's cell. The various
methods that I have found on the web all seem to not work such as:
GridView1.Rows[e.RowIndex].Cells[3].Text
This comes up as an empty string. The old way of doing things was
this in a datagrid:
e.Item.Cells[2].Controls[0])).Text
This stuff is for a C# method of updating the gridview. Everyone has suggested
using the control's built in features, but you know what??
I DO NOT WANT TO. lol. If you can help it will be much appreciated.
I am trying to set parameters to pass into a stored procedure.
ex:
VB Code:
sqlconn = new SqlConnection(); sqlconn.ConnectionString = ConfigurationManager.AppSettings["cs"]; insertWO = new SqlCommand("usp_Update_WORK_ITEMS", sqlconn); insertWO.CommandType = CommandType.StoredProcedure; insertWO.Parameters.Add("@WORK_DESC", SqlDbType.VarChar).Value = this.GridView1.Rows[e.RowIndex].Cells[3].Text; insertWO.Parameters.Add("@CRS_WO_ID", SqlDbType.Int).Value = Convert.ToInt32(this.GridView1.Rows[e.RowIndex].Cells[5].Text); insertWO.Parameters.Add("@STATUS_ID", SqlDbType.Int).Value = Convert.ToInt32(this.GridView1.Rows[e.RowIndex].Cells[4].Text); //insertWO.Parameters.Add("@TIME_SPENT", SqlDbType.DateTime).Value = Convert.ToDateTime(this.txtTimeSpent.Text.ToString()); insertWO.Parameters.Add("@COMPLETE_DT", SqlDbType.DateTime).Value = Convert.ToDateTime(this.GridView1.Rows[e.RowIndex].Cells[7].Text); insertWO.Parameters.Add("@START_DT", SqlDbType.DateTime).Value = Convert.ToDateTime(this.GridView1.Rows[e.RowIndex].Cells[8].Text); insertWO.Parameters.Add("@ID", SqlDbType.Int).Value = Convert.ToInt32(this.GridView1.Rows[e.RowIndex].Cells[2].Text); sqlconn.Open(); insertWO.ExecuteNonQuery();
This is returning an empty string except for the keyed field.
Thanks guys!!
Pol




Reply With Quote