【发布时间】:2015-10-30 17:57:25
【问题描述】:
我正在尝试从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();
}
【问题讨论】:
-
放码哥们,你怎么选的?复选框?