مساء الخير يا شباب
عندى Grid view عاوز اعمل منها delete ولكن المشكلة ان ال Grid view جواها Forign key فاللينك Delete مش بيشتغل ويجب كتابة كود داخل GridView1_RowDeleting event
انا كتبت هذا الكود
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string id = e.RowIndex.ToString();
SqlConnection con=new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand cmd=new SqlCommand("DELETE FROM Orders WHERE id = @id",con);
cmd.Parameters.Add("@id",SqlDbType.Int);
cmd.Parameters["@id"].Value=Convert.ToInt32(id);
try
{
con.Open();
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
Response.Write(ex);
}
finally
{
con.Close();
}
}المشكلة يا شباب ان لاحظت ان اوقات اللينك يقوم بالمسح من الداتا بيز واوقات اخرى لا يمسح واتوقع ان المشكلة تخص id
فممكن حد لو عنده فكرة ...... يرشدنا ....... وشكرا جزيلا .