日期:2014-05-18 浏览次数:20415 次
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemIndex != -1) { if (DataList1.Items.Count > 1) { foreach (DataRowView var in dv) { if (var["m_id"].ToString() == this.DataList1.DataKeys[e.Item.ItemIndex].ToString()) { (DataList1.Items[int.Parse(ViewState["count"].ToString()) + 2].FindControl("CheckBox5") as CheckBox).Checked = true; (DataList1.Items[int.Parse(ViewState["count"].ToString()) + 2].FindControl("CheckBox1") as CheckBox).Checked = bool.Parse(var["select"].ToString()); (DataList1.Items[int.Parse(ViewState["count"].ToString()) + 2].FindControl("CheckBox2") as CheckBox).Checked = bool.Parse(var["insert"].ToString()); (DataList1.Items[int.Parse(ViewState["count"].ToString()) + 2].FindControl("CheckBox3") as CheckBox).Checked = bool.Parse(var["update"].ToString()); (DataList1.Items[int.Parse(ViewState["count"].ToString()) + 2].FindControl("CheckBox4") as CheckBox).Checked = bool.Parse(var["delete"].ToString()); } } } else { return; } ViewState["count"] = int.Parse(ViewState["count"].ToString()) + 1; } }