在C#的ASP.NET Web应用程序中,DataGrid与数据库绑定,加入"编辑"、"选择"等按扭,按扭类型选“PushButtom”时为何不起作用? 我记得在beta2版时出现过这种问题,到了正式版一切正常 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你可以在itemcommand事件里试试private void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { switch(e.CommandName) { case "Select": //code break; } } 还要写代码啊给个例子private void DataGrid1_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { try { ErrorMessage.Text = ""; SqlCommand delCommand = new SqlCommand(); delCommand.Connection = sqlConnection1; delCommand.CommandText = "DELETE FROM Customers WHERE CustomerID = '" + e.Item.Cells[2].Text + "'"; delCommand.CommandType = CommandType.Text; sqlConnection1.Open(); delCommand.ExecuteNonQuery(); sqlDataAdapter1.Fill(dataSet1); Cache["CustomerData"] = dataSet1; bindGrid(); sqlConnection1.Close(); } catch (Exception ex) { ErrorMessage.Text = ex.Message; } } 关于用UpdatePanel取不到值的问题 求个计算每个页面访问量的解决方案 招商 推荐:你有每天记账的习惯吗?欢迎使用B/S版个人财务系统。 asp.net 编译工具 在线等 asp.net 连接不上Access数据库 关于ado的乱码 请指点一个sql语句!急用! css问题,给控件设置的CSS不起作用。 字体大小,在线等待 服务器端控件之间怎么互相访问啊? 我想知道在线用户具体有那些?
{
switch(e.CommandName)
{
case "Select":
//code
break;
}
}
给个例子
private void DataGrid1_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
try
{
ErrorMessage.Text = "";
SqlCommand delCommand = new SqlCommand();
delCommand.Connection = sqlConnection1;
delCommand.CommandText = "DELETE FROM Customers WHERE CustomerID = '" + e.Item.Cells[2].Text + "'";
delCommand.CommandType = CommandType.Text;
sqlConnection1.Open();
delCommand.ExecuteNonQuery();
sqlDataAdapter1.Fill(dataSet1);
Cache["CustomerData"] = dataSet1;
bindGrid();
sqlConnection1.Close();
}
catch (Exception ex)
{
ErrorMessage.Text = ex.Message;
}
}