Sai Avinash
Sai Avinash

Reputation: 4753

How to make a drop down read only inside a grid view after binding

I am using grid view which contains a drop down list inside it along with other controls. I am sucessfully binding the data selected from database. but, i want to know is there any way to make this drop down as read only.. Please help..and ReadOnly="True" is not working

Upvotes: 1

Views: 1254

Answers (1)

Suraj Singh
Suraj Singh

Reputation: 4059

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow))
    {

        DataRow row = ((DataRowView)e.Row.DataItem).Row;

        DropdownList ddlxxx= (DropDownList)e.Row.FindControl("ddlName");               
         //This will make your ddl readonly 
         ddlxxx.Enabled = false;
    }
}

Upvotes: 1

Related Questions