One column in a DataGrid has a DropDownList displaying locations but right now its only displaying the same location for each row, not the correct location.

    protected void PopulateDDLs(DropDownList ddlTrailerLoc)
    {
        DataSet dsTrailerLocation = DataUtils.GetAllGenSmall(Company.Current.CompanyID, "Description", "", 1, false, "Description", false, "TrailerLocationNOCODE", 0);
        if (dsTrailerLocation.Tables[0].Rows.Count > 0)
        {
            ddlTrailerLoc.DataSource = dsTrailerLocation;
            ddlTrailerLoc.DataValueField = "Description";
            ddlTrailerLoc.DataTextField = "Description";
            ddlTrailerLoc.DataBind();
        }
        else
        {
            ddlTrailerLoc.Items.Insert(0, new ListItem("No Locations Entered", "0"));
        }
    }

protected void dgList_ItemCreated(object sender, DataGridItemEventArgs e)
    {
DropDownList ddlTrailerLocation = e.Item.FindControl("ddlTrailerLoc") as DropDownList;
             DataSet dsTrailerLocation = DataUtils.GetAllGenSmall(Company.Current.CompanyID, "Description", "", 1, false, "Description", false, "TrailerLocationNOCODE", 0);
             if (ddlTrailerLocation != null)
             {
                 PopulateDDLs(ddlTrailerLocation);
             }
        }

Related posts

Recent Viewed