1
我试图从gridview
中删除选中的行(选定),但选定的行不会删除。为什么?从gridview中删除选中的行
//Class-Method
public void DeleteDataRow(string ID)
{
using (SqlCommand xComm = new SqlCommand())
{
Conn.Open();
new SqlCommand("Delete from Costumers Where CID='" + ID + "' ", Conn);
Conn.Close();
}
}
//webform-Method
protected void xbutton_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GV.Rows)
{
CheckBox C = row.Cells[0].FindControl("Check") as CheckBox;
string ID= row.Cells[1].Text;
if(C.Checked)
{
m.DeleteDataRow(ID);
}
}
GV.DataSource = m.Select();
GV.DataBind();
}
把代码花花公子,你怎么选择?复选框? –