我有nested-datalist
孩子datalist
,itemcommand
事件我正在做这样的事情
if (e.CommandName == "Delete")
{
string keyID;
int idx = e.Item.ItemIndex;
DataClasses1DataContext db = new DataClasses1DataContext();
DataList dl = Session["dl"] as DataList;
object thisKey = dl.DataKeys[idx];
keyID = thisKey.ToString();
foreach (DataListItem item in dl.Items)
{
LinkButton lb = item.FindControl("LinkButton1") as LinkButton;
ImageButton ib = item.FindControl("ImageButton1") as ImageButton;
string s = item.ItemIndex.ToString();
string j = s;
if (item.ItemIndex == idx)
{
string dds = ib.AlternateText;
Label ServiceCommentIDLabel = item.FindControl("ServiceCommentIDLabel") as Label;
string ds = ServiceCommentIDLabel.Text;
ServiceComment sc = db.ServiceComments.Where(o => o.ServiceCommentID == long.Parse(ServiceCommentIDLabel.Text)).First();
db.ServiceComments.DeleteOnSubmit(sc);
Response.Redirect("Services.aspx");
}
}
}
它既不是选择精确的,datakey
也不是foreach
遍历每个item
.datalist