代码我觉得对的,为什么DataGrid数据删除不了,按了BUTTON没反应
代码如下,运行时不报任何错误信息
<asp:datagrid id="DataGrid1" Font-Size="13px" Width="570" Runat="server" AutoGenerateColumns="False" BackImageUrl="photo\bg2.gif" BorderColor="#0099CC" BorderWidth="2px" CellPadding="5" OnItemCommand="dele">
<AlternatingItemStyle HorizontalAlign="Center" BorderStyle="None" BackColor="#E0E0E0"></AlternatingItemStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<HeaderStyle HorizontalAlign="Center" BackColor="PapayaWhip"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="carid" HeaderText="序号"></asp:BoundColumn>
<asp:BoundColumn DataField="ticket_name" HeaderText="演出票名"></asp:BoundColumn>
<asp:BoundColumn DataField="ticket_price" HeaderText="单价:元/张"></asp:BoundColumn>
<asp:BoundColumn DataField="ticket_shopnum" HeaderText="数量"></asp:BoundColumn>
<asp:BoundColumn DataField="allprice" HeaderText="小计(元)"></asp:BoundColumn>
<asp:ButtonColumn HeaderText="删除" Text="删除" ButtonType="PushButton"></asp:ButtonColumn>
</Columns>
</asp:datagrid>
<script language="C#" runat="server">
void dele(object sender,System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
sqlcon = new SqlConnection("server=.;user=sa;database=ticket");
string strsql="delete from shopcar where carid="+Convert.ToInt32(e.Item.Cells[1].Text);
sqlcmd = new SqlCommand(strsql,sqlcon);
sqlcon.Open();
sqlcmd.ExecuteNonQuery();
sqlcon.Close();
bangding();
}
void bangding()
{
sqldar = new SqlDataAdapter("select * from shopcar","server=.;user=sa;database=ticket");
DataSet ds = new DataSet();
sqldar.Fill(ds,"shopcar");
DataView dv = ds.Tables[0].DefaultView;
this.DataGrid1.DataSource=dv;
this.DataGrid1.DataBind();
}
</script>
[此贴子已经被作者于2006-11-30 20:22:24编辑过]