Saturday, April 16, 2011

Grid View Edit Bring DropDown to Select Values

protected void GrdStudyList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow && (e.Row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit)
            {
                DropDownList DDLModalityName = (DropDownList)e.Row.FindControl("DDLGridModalityName");
                DataSet DDLBind = _ObjBal.GetModalityIdAndName();
                DDLModalityName.DataSource = DDLBind;
                DDLModalityName.DataTextField = "CorpModalityName";
                DDLModalityName.DataValueField = "CorpModalityID";
                DDLModalityName.DataBind();
                DDLModalityName.Items.Insert(0, new ListItem("Select", "0"));
                DDLModalityName.SelectedValue = Convert.ToString(GrdStudyList.DataKeys[e.Row.RowIndex]["ModalityTypeID"].ToString());
                DropDownList DDLGender = (DropDownList)e.Row.FindControl("DDLGrdGender");
                DDLGender.SelectedValue = Convert.ToString(GrdStudyList.DataKeys[e.Row.RowIndex]["Gender"].ToString());
                DropDownList DDLStudyType = (DropDownList)e.Row.FindControl("DDLGridStudyType");
                DDLStudyType.SelectedValue = Convert.ToString(GrdStudyList.DataKeys[e.Row.RowIndex]["BillingType"].ToString());
            }
        }

No comments:

Post a Comment