Hi there,
I am using the delete command within ASP DataGrid. When I click the delete link on the datagrid, I get the following error:
<
Please reply as soon as possible
Hi there,
I am using the delete command within ASP DataGrid. When I click the delete link on the datagrid, I get the following error:
<
Please reply as soon as possible
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Yogesh VermaRank #3,483 · 416 reputationPosted Apr 8, 2008, 1:44 AM EDT
Check your code...find right Cell[] value.
or send Code part................
rahul pawar14 reputationPosted Apr 8, 2008, 3:42 AM EDT
{
string Query = "delete from shiftshedule where emp_name='"+ ((TextBox)GridView1.Rows[GridView1.EditIndex].Cells[2].Controls[0]).Text +"' and date1='"+((TextBox)GridView1.Rows[GridView1.EditIndex].Cells[1].Controls[0]).Text +"'";
SqlConnection ObjConnection = new SqlConnection("Data Source=(local);Initial Catalog=Northwind;User ID=sa;password=sa;");
ObjConnection.Open();
SqlCommand ObjCommand = new SqlCommand(Query, ObjConnection);
ObjCommand.ExecuteNonQuery();
//ObjReader.Dispose();
ObjCommand.Dispose();
SqlDataAdapter ObjAdapter = new SqlDataAdapter("select date1,emp_name,availibility from ShiftShedule where emp_name='" + DropName.SelectedItem.Text + "' and date1 between '" + txtFrom.Text + "' and '" + txtTo.Text + "' ", ObjConnection);
DataSet ObjDataSet = new DataSet();
ObjAdapter.Fill(ObjDataSet, "rahul");
GridView1.DataSource = ObjDataSet.Tables["rahul"];
GridView1.DataBind();
}
Rafiq Batcha18 reputationPosted Apr 10, 2008, 11:32 AM EDT