You have to use the DataItem
of the GridViewRow
to access the underyling record. Then you can select the corect item via DropDownList.SelectedValue
:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//Find the DropDownList in the Row
DropDownList ddlManager = (e.Row.FindControl("ddlManager") as DropDownList);
DataSet ds = DataBaseConnectivity.GetData
("select distinct [isManager] from tblUsersTable");
ddlManager.DataSource = ds;
ddlManager.DataTextField = "isManager";
ddlManager.DataValueField = "isManager";
ddlManager.DataBind();
ddlManager.Items.Insert(0, new ListItem("Please select","-1"));
DataRow row = ((DataRowView)e.Row.DataItem).Row;
bool isManager= row.Field<bool>("isManager"); // use the correct type if it's not bool
ddlManager.SelectedValue = isManager.ToString();
Apart from that, i would not use such db-helper classes like DataBaseConnectivity
in ASP.NET. They are just a source for nasty errors or performance issues, all the more if you use a static connection. Further informations here.