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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rafiq BatchaPosted Apr 10, 2008, 3:32 PM
rahul pawarPosted Apr 8, 2008, 7:42 AM
{
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();
}
Yogesh VermaPosted Apr 8, 2008, 5:44 AM
Check your code...find right Cell[] value.
or send Code part................