// Here new SQL query is pass to the SQL command object to get the data from tbl_order_status table.
mySqlCommand = new SqlCommand("select * from tbl_order_status", mySQLconnection);
mySqlAdapter = new SqlDataAdapter(mySqlCommand);
myDataSet = new DataSet();
mySqlAdapter.Fill(myDataSet);
// DropDownList Control Object Created to bind the data dynamically with each nested DropDownlist control placed inside the template column of the GridView Control.
DropDownList drdList;
// foreach loop is used to loop through each row of GridView Control.
foreach (GridViewRow grdRow in GridView1.Rows)
{
// Nested DropDownList Control reference is passed to the DrdList object. This will allow you access the properties of dropdownlist placed inside the GridView Template column.
drdList = (DropDownList)( GridView1.Rows[ grdRow.RowIndex ].Cells[1].FindControl( "DropDownList1" ));
// DataBinding of nested DropDownList Control for each row of GridView Control.
drdList.DataSource = myDataSet;
drdList.DataValueField = "order_status_id";
drdList.DataTextField = "order_status_name";
drdList.DataBind();
}