protected void ddlGroupParent_Load() { DropDownList drdList; BWorkGroup obj = new BWorkGroup(); // foreach loop is used to loop through each row of GridView Control. foreach (GridViewRow grdRow in grvWorkGroup.Rows) { // Nested DropDownList Control reference is passed to the DrdList object. This will allow you access the properties of dropdownlist placed inside the GridView Template column. drdList = (DropDownList)(grvWorkGroup.Rows[grdRow.RowIndex].Cells[4].FindControl("ddlGroupParent")); // DataBinding of nested DropDownList Control for each row of GridView Control. ListItem lit = new ListItem("Không có nhóm công việc cha", "0"); drdList.DataSource = obj.Get(0); drdList.DataValueField = "WorkGroupID"; drdList.DataTextField = "Name"; drdList.DataBind(); drdList.Items.Insert(0, lit); int Id = Convert.ToInt32(grvWorkGroup.DataKeys[grdRow.RowIndex].Value); int IdParent = obj.Get(Id).First().WorkGroupParent; if (IdParent == 0) { drdList.SelectedValue = "0"; } else { drdList.SelectedValue = IdParent.ToString(); } } }
protected void ddlWorkGroup_Load() { ddlWorkGroup.Items.Clear(); BWorkGroup bwg = new BWorkGroup(); ddlWorkGroup.DataSource = bwg.Get(0); ddlWorkGroup.DataTextField = "Name"; ddlWorkGroup.DataValueField = "WorkGroupID"; ddlWorkGroup.DataBind(); }
protected void ddlWorkGroup_Load() { ListItem lit = new ListItem("--Chọn nhóm công việc--", "0"); BWorkGroup bwg = new BWorkGroup(); ddlWorkGroup.DataSource = bwg.Get(0); ddlWorkGroup.DataTextField = "Name"; ddlWorkGroup.DataValueField = "WorkGroupID"; ddlWorkGroup.DataBind(); ddlWorkGroup.Items.Insert(0, lit); }
protected void grvWorkGroup_Load() { BWorkGroup objWorkGroup = new BWorkGroup(); int count = objWorkGroup.Get(0).Count; ctlPagging.PageSize = int.Parse(ddlPageSize.SelectedValue); spResultCount.InnerHtml = "Tìm thấy <b>" + count.ToString() + "</b> kết quả"; if (count > ctlPagging.PageSize) { ctlPagging.Visible = true; } else { ctlPagging.Visible = false; } grvWorkGroup.DataSource = objWorkGroup.Get(0, CurrentPage, ctlPagging.PageSize); grvWorkGroup.DataBind(); ddlGroupParent_Load(); ctlPagging.CurrentIndex = CurrentPage; ctlPagging.ItemCount = count; ctlPagging.QueryStringParameterName = GenarateParam(); }