0

I tried to change a dropdownlist.enabled which in gridview row.

i write this code block.

            if (isEdit && index == e.Row.RowIndex)
            {
                foreach (GridViewRow item in GridView1.Rows)
                {
                    if (item.RowIndex == index)
                    {
                        DataRowView rowView2 = (DataRowView)item.DataItem;
                        DDL = (DropDownList)item.FindControl("ddlLocation");
                        DDL.Enabled = true;
                        isEdit = false;
                    }
                }

             }

and get isEdit from GridView1_RowEditing

like :

  isEdit = true;

and get index from row command like :

        if (e.CommandName == "Edit")
        {
            index = Convert.ToInt32(e.CommandArgument);
        }

is anyone can help me ?

1 Answer 1

1

You should be able to simplify your code down to just this:

if (isEdit)
{
    DropDownList DDL = (DropDownList)GridView1.Rows[index].FindControl("ddlLocation");
    DDL.Enabled = true;
    isEdit = false;
 }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.