protected void gridMain_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { int recSkip = gridMain.CurrentPageIndex * gridMain.PageSize; int recTake = gridMain.PageSize; try { LineTypesController cont = new LineTypesController(); gridMain.VirtualItemCount = cont.CountLineTypes(); gridMain.DataSource = cont.GetLineTypes(recSkip, recTake); } catch (Exception) { } }
protected void gridMain_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridEditableItem && e.Item.IsInEditMode) { CustomerID = -1; Session.Remove("CustomerID"); LineTypeID = -1; Session.Remove("LineTypeID"); GridEditableItem item = e.Item as GridEditableItem; RadDropDownList ddlCustomer = item.FindControl("ddlCustomer") as RadDropDownList; RadDropDownList ddlLineType = item.FindControl("ddlLineType") as RadDropDownList; try { CountryPricelistB currPricelist = e.Item.DataItem as CountryPricelistB; CustomersController cont = new CustomersController(); ddlCustomer.DataSource = cont.GetProviders(); ddlCustomer.DataTextField = "NameGR"; ddlCustomer.DataValueField = "ID"; ddlCustomer.DataBind(); LineTypesController cont2 = new LineTypesController(); ddlLineType.DataSource = cont2.GetLineTypes(); ddlLineType.DataTextField = "Name"; ddlLineType.DataValueField = "ID"; ddlLineType.DataBind(); if (currPricelist != null) { ddlCustomer.SelectedIndex = ddlCustomer.FindItemByValue(currPricelist.CustomerID.ToString()).Index; Session["CustomerID"] = currPricelist.CustomerID; ddlLineType.SelectedIndex = ddlLineType.FindItemByValue(currPricelist.LineTypeID.ToString()).Index; Session["LineTypeID"] = currPricelist.LineTypeID; } else { ddlCustomer.SelectedIndex = 0; Session["CustomerID"] = ddlCustomer.SelectedItem.Value; ddlLineType.SelectedIndex = 0; Session["LineTypeID"] = ddlLineType.SelectedItem.Value; } } catch (Exception) { } } }