0
嗨gusy即时通讯试图了解如何从数据库中删除使用grindview与复选框,但我不知道为什么deleteresults.text和DeleteResults.Visible不工作这是我的代码(即编程新:)和thx for你的答案使用复选框从gridview删除
protected void Button3_Click(object sender, EventArgs e)
{
bool atLeastOneRowDeleted = false;
// Iterate through the Products.Rows property
foreach (GridViewRow row in Products.Rows)
{
// Access the CheckBox
CheckBox cb = (CheckBox)row.FindControl("selector");
if (cb != null && cb.Checked)
{
// Delete row! (Well, not really...)
atLeastOneRowDeleted = true;
// First, get the ProductID for the selected row
int id_offre = Convert.ToInt32(Products.DataKeys[row.RowIndex].Value);
// "Delete" the row
DeleteResults.Text += string.Format("This would have deleted ProductID {0}<br />", id_offre);
}
}
// Show the Label if at least one row was deleted...
DeleteResults.Visible = atLeastOneRowDeleted;
}
那么发生了什么,没有发生?有没有错误或只是没有做任何事情? –
哪一行给出错误? –
我运行的网页,我点击复选框,然后我点击o删除我有错误的行int id_offre = Convert.ToInt32(Products.DataKeys [row.RowIndex] .Value); “indexis out of limites can be negative” –