コード例 #1
0
    protected void grdStateWiseLeadsAllocation_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DataSet dsFillCenters = new DataSet();
            if (Cache["Centers"] == null)
            {
                dsFillCenters    = objHotLeadBL.GetMasterAgentCenters();
                Cache["Centers"] = dsFillCenters;
            }
            else
            {
                dsFillCenters = Cache["Centers"] as DataSet;
            }

            DropDownList ddlDropDownList = (DropDownList)e.Row.FindControl("ddlDropDownList");

            ddlDropDownList.DataSource     = dsFillCenters.Tables[0];
            ddlDropDownList.DataTextField  = "AgentCenterCode";
            ddlDropDownList.DataValueField = "AgentCenterID";
            ddlDropDownList.DataBind();
            ddlDropDownList.Items.Insert(0, new ListItem("Select", "0"));

            HiddenField hdnCenterID = (HiddenField)e.Row.FindControl("hdnCenterID");

            if (hdnCenterID.Value != "")
            {
                ddlDropDownList.SelectedIndex = ddlDropDownList.Items.IndexOf(ddlDropDownList.Items.FindByValue(hdnCenterID.Value));
            }
        }
    }