Check this following code
protected void Gridview1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connection"].ConnectionString);
DropDownList ddlDropDownList = (DropDownList)e.Row.FindControl("ddl1");
if (ddlDropDownList != null)
{
SqlDataAdapter da = new SqlDataAdapter("select distinct(source) from pickupdroptariff", con);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
ddlDropDownList.DataSource = dt;
ddlDropDownList.DataTextField = "source";
ddlDropDownList.DataValueField = "source";
ddlDropDownList.DataBind();
ddlDropDownList.Items.Insert(0, "--Select--");
}
else
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('Source Not Available');", true);
}
}
}