gridview中按钮控件点击无反应
代码:<asp:TemplateField><ItemTemplate><asp:ButtonID="button"runat="server"CommandName="...
代码:
<asp:TemplateField><ItemTemplate><asp:Button ID="button" runat="server" CommandName="delete" Text="删除" /></ItemTemplate></asp:TemplateField>
CommandName="delete" ,这个也加了,点击删除按钮,页面只是刷新了一下
GridViewRow gr = this.GridView1.Rows[e.RowIndex];
CheckBox chk = (CheckBox)gr.Cells[0].FindControl("checkbox");
if (chk.Checked == true)
{
string RoomNo = gr.Cells[1].Text;
SqlConnection con = new SqlConnection("server=ADMIN-PC\\SQL2005;database=StudentBuildingManage;trusted_connection=true;");
con.Open();
SqlCommand cmd = new SqlCommand("delete from roomInfo where roomNo='" + RoomNo + "'", con); 展开
<asp:TemplateField><ItemTemplate><asp:Button ID="button" runat="server" CommandName="delete" Text="删除" /></ItemTemplate></asp:TemplateField>
CommandName="delete" ,这个也加了,点击删除按钮,页面只是刷新了一下
GridViewRow gr = this.GridView1.Rows[e.RowIndex];
CheckBox chk = (CheckBox)gr.Cells[0].FindControl("checkbox");
if (chk.Checked == true)
{
string RoomNo = gr.Cells[1].Text;
SqlConnection con = new SqlConnection("server=ADMIN-PC\\SQL2005;database=StudentBuildingManage;trusted_connection=true;");
con.Open();
SqlCommand cmd = new SqlCommand("delete from roomInfo where roomNo='" + RoomNo + "'", con); 展开
2个回答
展开全部
前台代码
OnRowDeleting="GridView_RowDeleting"
<asp:TemplateField HeaderText="操作">
<ItemTemplate>
<asp:LinkButton ID="lbtn_Del" runat="server" CausesValidation="False" CommandName="Delete"
Text="删除" OnClientClick="javascript:return confirm('是否删除!')"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
后台
protected void GridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
//执行删除操作
}
OnRowDeleting="GridView_RowDeleting"
<asp:TemplateField HeaderText="操作">
<ItemTemplate>
<asp:LinkButton ID="lbtn_Del" runat="server" CausesValidation="False" CommandName="Delete"
Text="删除" OnClientClick="javascript:return confirm('是否删除!')"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
后台
protected void GridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
//执行删除操作
}
更多追问追答
追问
protected void GridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
//执行删除操作
}
后台代码是在这里写的。但是还是不行啊
追答
你把你的代码发给我,我看下,
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询