.aspx
......
OnDeleteCommand="DataGrid1_Delete"
......
<asp:ButtonColumn Text="删除" CommandName="Delete">
<ItemStyle Width="50px"></ItemStyle>
</asp:ButtonColumn>.aspx.cs
public void DataGrid1_Delete(object sender, DataGridCommandEventArgs e)
{
//相关代码
SqlConnection myConn=new SqlConnection(...);
string deletestr="...";
.....
SqlCommand mycommand=new SqlCommand(deletestr,myConn);
mycommand.Connection.Open();
mycommand.ExecuteNonQuery();
mycommand.Connection.Close();
....
}
......
OnDeleteCommand="DataGrid1_Delete"
......
<asp:ButtonColumn Text="删除" CommandName="Delete">
<ItemStyle Width="50px"></ItemStyle>
</asp:ButtonColumn>.aspx.cs
public void DataGrid1_Delete(object sender, DataGridCommandEventArgs e)
{
//相关代码
SqlConnection myConn=new SqlConnection(...);
string deletestr="...";
.....
SqlCommand mycommand=new SqlCommand(deletestr,myConn);
mycommand.Connection.Open();
mycommand.ExecuteNonQuery();
mycommand.Connection.Close();
....
}
newsid = Request.Params["aaid"];
try
{
sel="delete from aa WHERE aaid="+newsid;
sqlCommand1=new System.Data.SqlClient.SqlCommand (sel,sqlConnection1);
sqlCommand1.Connection.Open();
sqlCommand1.ExecuteNonQuery();
sqlCommand1.Connection.Close(); sqlDataAdapter1.Fill(dataSet151);
dgd1.DataBind();
}
--------------------------------------------------------------------------------无法找到资源。说明: HTTP 404。您正在查找的资源(或者它的一个依赖项)可能已被移除,或其名称已更改,或暂时不可用。请检查以下 URL 并确保其拼写正确。 请求的 URL: /WebApplication11/WebFrom10.aspx
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573
这问题我也郁闷了好几天,看着页面上没有了,但数据库里还有。别习的用DataGrid,太麻烦,还不如普通的COMMAND,呢
俺是刚学,不一定对,高手再指点
sel="delete from aa WHERE aaid="+newsid;
sqlCommand1=new System.Data.SqlClient.SqlCommand (sel,sqlConnection1);
sqlCommand1.Connection.Open();
sqlCommand1.ExecuteNonQuery();
sqlCommand1.Connection.Close(); sqlDataAdapter1.Fill(dataSet151);
dgd1.DataBind();
删掉所选的记录,他老是出现
“/WebApplication11”应用程序中的服务器错误。
--------------------------------------------------------------------------------无法找到资源。说明: HTTP 404。您正在查找的资源(或者它的一个依赖项)可能已被移除,或其名称已更改,或暂时不可用。请检查以下 URL 并确保其拼写正确。 请求的 URL: /WebApplication11/WebFrom10.aspx
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573